Files
OpenList/drivers/alist/alist.go

45 lines
815 B
Go
Raw Normal View History

2021-12-08 09:10:00 +08:00
package alist
import (
"errors"
"github.com/Xhofe/alist/drivers/base"
"github.com/Xhofe/alist/model"
)
type BaseResp struct {
Code int `json:"code"`
Message string `json:"message"`
}
type PathResp struct {
BaseResp
2022-01-02 14:44:14 +08:00
Data struct {
Type string `json:"type"`
//Meta Meta `json:"meta"`
Files []model.File `json:"files"`
} `json:"data"`
2021-12-08 09:10:00 +08:00
}
type PreviewResp struct {
BaseResp
Data interface{} `json:"data"`
}
func (driver *Alist) Login(account *model.Account) error {
var resp BaseResp
_, err := base.RestyClient.R().SetResult(&resp).
SetHeader("Authorization", account.AccessToken).
2022-01-02 14:44:14 +08:00
Get(account.SiteUrl + "/api/admin/login")
2021-12-08 09:10:00 +08:00
if err != nil {
return err
}
if resp.Code != 200 {
return errors.New(resp.Message)
}
return nil
}
func init() {
base.RegisterDriver(&Alist{})
}