api

package
v0.18.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 11, 2024 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrInvalidOp   = `invalid patch op: "%s"`
	ErrInvalidPath = `invalid patch path: "%s"`
)
View Source
const MagicUIDKey string = "_magic_uid_key_"
View Source
const Version = "v0.18.0"

Variables

View Source
var (
	ErrAuthNotExist   = errors.New("webhook/api: Authorization does not exist")
	ErrBlogNotExist   = errors.New("webhook/api: blog does not exist")
	ErrUserNotExist   = errors.New("webhook/api: user does not exist")
	ErrTaskNotExist   = errors.New("webhook/api: task does not exist")
	ErrFilterNotExist = errors.New("webhook/api: filter does not exist")

	ErrExpired    = errors.New("webhook/api: token is expired")
	ErrPermDenied = errors.New("webhook/api: permission denied")

	ErrUserRegistered = errors.New("webhook/api: user registered")
	ErrIncorrectPwd   = errors.New("webhook/api: incorrect password")
	ErrBanned         = errors.New("webhook/api: user has been banned")
)
View Source
var AutoDownload bool

开启自动下载会极大的占用带宽 建议发送完所有 hook 请求后再下载

Functions

func BlogDB added in v0.15.0

func BlogDB() *gorm.DB

func CloseDB added in v0.15.0

func CloseDB() error

func Default added in v0.15.0

func Default() (r *gin.Engine)

func DeleteTaskID added in v0.15.0

func DeleteTaskID(ctx *gin.Context) (any, error)

移除任务

func DownloadAssets added in v0.18.0

func DownloadAssets(blog *model.Blog)

下载资源

func Error added in v0.10.0

func Error(ctx *gin.Context, err error)

func Get added in v0.15.0

func Get(ctx *gin.Context) (any, error)

获取自身信息

func GetBlogID added in v0.15.0

func GetBlogID(ctx *gin.Context) (any, error)

查询单条博文

func GetBlogs added in v0.15.0

func GetBlogs(ctx *gin.Context) (any, error)

查询博文

func GetExecute added in v0.17.0

func GetExecute(ctx *gin.Context) (any, error)

func GetOnline added in v0.14.0

func GetOnline(ctx *gin.Context) (any, error)

获取当前在线状态

func GetPing added in v0.14.0

func GetPing(ctx *gin.Context) (any, error)

更新在线时间

func GetShutdown added in v0.15.0

func GetShutdown(ctx *gin.Context) (any, error)

func GetTaskID added in v0.15.0

func GetTaskID(ctx *gin.Context) (any, error)

获取任务

func GetToken

func GetToken(ctx *gin.Context) (data any, err error)

获取 Token

func GetUID added in v0.15.0

func GetUID(ctx *gin.Context) string

func GetUUID added in v0.15.0

func GetUUID(ctx *gin.Context) (any, error)

获取用户信息

func GetUserUID added in v0.15.0

func GetUserUID(ctx *gin.Context) (any, error)

func GetValid added in v0.16.0

func GetValid(ctx *gin.Context) (any, error)

检验鉴权码是否有效

func GetVersion added in v0.14.0

func GetVersion(ctx *gin.Context) (any, error)

当前版本号

func Index added in v0.18.0

func Index(ctx *gin.Context)

func Info added in v0.15.0

func Info(ctx *gin.Context)

func IsAdmin added in v0.14.0

func IsAdmin(ctx *gin.Context)

func IsOwner added in v0.15.0

func IsOwner(ctx *gin.Context)

func IsUser added in v0.15.0

func IsUser(ctx *gin.Context)

func JWTAuth added in v0.15.0

func JWTAuth(ctx *gin.Context) (uid string, err error)

func JWTSecretKey added in v0.15.0

func JWTSecretKey(*jwt.Token) (any, error)

func JWTUser added in v0.15.0

func JWTUser(ctx *gin.Context) (user *model.User, err error)

func LoadDir added in v0.18.0

func LoadDir(root, path string) error

func LoadFile added in v0.18.0

func LoadFile(root, file string)

func Log added in v0.15.0

func Log() *logrus.Logger

func LogMiddleware added in v0.15.0

func LogMiddleware(ctx *gin.Context)

func New added in v0.15.0

func New() (r *gin.Engine)

func PatchTaskID added in v0.15.0

func PatchTaskID(ctx *gin.Context) (any, error)

修改任务

func PatchUser added in v0.15.0

func PatchUser(ctx *gin.Context) (any, error)

修改用户信息

func PatchUserBan added in v0.15.0

func PatchUserBan(ctx *gin.Context, me, user *model.User, patch PatchBody) error

func PatchUserName added in v0.15.0

func PatchUserName(ctx *gin.Context, me, user *model.User, patch PatchBody) error

func PatchUserNickname added in v0.15.0

func PatchUserNickname(ctx *gin.Context, me, user *model.User, patch PatchBody) error

func PatchUserRole added in v0.15.0

func PatchUserRole(ctx *gin.Context, me, user *model.User, patch PatchBody) error

func PostBlog added in v0.15.0

func PostBlog(ctx *gin.Context) (any, error)

提交博文

func PostFilter added in v0.17.0

func PostFilter(ctx *gin.Context) (any, error)

筛选查询

func PostRegister added in v0.15.0

func PostRegister(ctx *gin.Context) (any, error)

新建用户

func PostTask added in v0.15.0

func PostTask(ctx *gin.Context) (any, error)

新增任务

func PostTest added in v0.15.0

func PostTest(ctx *gin.Context) (any, error)

测试单个任务

func PostTests added in v0.15.0

func PostTests(ctx *gin.Context) (any, error)

测试已有任务

func PostUpload added in v0.18.0

func PostUpload(ctx *gin.Context) (any, error)

上传文件

func UserDB added in v0.15.0

func UserDB() *gorm.DB

Types

type PatchBody added in v0.15.0

type PatchBody struct {
	Op    string `json:"op"` // [replace, add, remove, move, copy, test]
	Path  string `json:"path"`
	Value string `json:"value,omitempty"`
	From  string `json:"from,omitempty"`
}

type UserClaims added in v0.15.0

type UserClaims struct {
	UID      string `json:"uid" gorm:"primaryKey"`
	IssuedAt int64  `json:"iat"`
}

func (UserClaims) TableName added in v0.17.3

func (UserClaims) TableName() string

func (UserClaims) Token added in v0.15.0

func (c UserClaims) Token(update bool) (string, error)

func (UserClaims) Valid added in v0.15.0

func (c UserClaims) Valid() error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL