Documentation
¶
Index ¶
- Constants
- Variables
- func AnyForwardURL(ctx *gin.Context) (any, error)
- func CloseDB() error
- func DeduplicateFilters(filters []model.Filter) (result []model.Filter)
- func DeleteTaskID(ctx *gin.Context) (any, error)
- func DownloadAssets(blog *model.Blog) error
- func Error(ctx *gin.Context, err error)
- func GetBlogID(ctx *gin.Context) (any, error)
- func GetBlogs(ctx *gin.Context) (any, error)
- func GetExecute(ctx *gin.Context) (any, error)
- func GetFollowing(ctx *gin.Context) (any, error)
- func GetOnline(ctx *gin.Context) (any, error)
- func GetPing(ctx *gin.Context) (any, error)
- func GetShutdown(ctx *gin.Context) (any, error)
- func GetTaskID(ctx *gin.Context) (any, error)
- func GetTasks(ctx *gin.Context) (any, error)
- func GetToken(ctx *gin.Context) (data any, err error)
- func GetUID(ctx *gin.Context) string
- func GetUser(ctx *gin.Context) (any, error)
- func GetUserUID(ctx *gin.Context) (any, error)
- func GetValid(ctx *gin.Context) (any, error)
- func GetVersion(ctx *gin.Context) (any, error)
- func Index(ctx *gin.Context)
- func Info(ctx *gin.Context)
- func Initial(cfg *Config) error
- func IsAdmin(ctx *gin.Context)
- func IsOwner(ctx *gin.Context)
- func IsUser(ctx *gin.Context)
- func JWTAuth(ctx *gin.Context) (uid string, err error)
- func LoadDir(root, path string) error
- func LoadFile(root, file string)
- func LoadOrStore[T any](extra map[string]any, key string, value T) (actual T, loaded bool)
- func LoggerConvertor(f group.HandlerFunc) gin.HandlerFunc
- func PatchTaskID(ctx *gin.Context) (any, error)
- func PatchUserBan(ctx *gin.Context, me, user *model.User, patch PatchBody) error
- func PatchUserName(ctx *gin.Context, me, user *model.User, patch PatchBody) error
- func PatchUserNickname(ctx *gin.Context, me, user *model.User, patch PatchBody) error
- func PatchUserRole(ctx *gin.Context, me, user *model.User, patch PatchBody) error
- func PatchUserUID(ctx *gin.Context) (any, error)
- func PostBlog(ctx *gin.Context) (any, error)
- func PostBlogs(ctx *gin.Context) (any, error)
- func PostTask(ctx *gin.Context) (any, error)
- func PostTest(ctx *gin.Context) (any, error)
- func PostUpload(ctx *gin.Context) (any, error)
- func PostUser(ctx *gin.Context) (any, error)
- type Condition
- type Config
- type PatchBody
- type Path
- type Role
- type Server
- type UserClaims
Constants ¶
View Source
const ( ErrInvalidOp = `invalid patch op: "%s"` ErrInvalidPath = `invalid patch path: "%s"` )
View Source
const ( Version string = "v0.19.0" Success string = "success" )
View Source
const AutoDownloadKey string = "auto_download"
View Source
const AutoSaveKey string = "auto_save"
View Source
const JWTSecretKeyKey string = "jwt_secret_key"
View Source
const MagicUIDKey string = "_magic_uid_key_"
Variables ¶
View Source
var ( ErrOpenAPINotExist = errors.New("webhook/api: OpenAPI does not exist") 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 请求后再下载
View Source
var AutoSave bool
自动另存数据库
View Source
var Backend = group.Group{ Middlewares: group.M{group.CORS, Index}, CustomFunc: func(r gin.IRouter) { downloader = utils.NewDownloader(config.Path.Full.Public) r.StaticFS("/public", downloader) }, HandlerMap: map[string]group.HandlerFunc{ "/forward/*url": AnyForwardURL, }, Groups: group.G{api}, }
后端
实现了前端页面、获取资源、请求转发
View Source
var JWTSecretKey []byte
用于 JWT 加密的密钥
View Source
var JWTSecretKeyFn = func(*jwt.Token) (any, error) { return JWTSecretKey, nil }
View Source
var UserDB, BlogDB *gorm.DB
Functions ¶
func AnyForwardURL ¶ added in v0.19.0
请求转发 https://blog.csdn.net/qq_29799655/article/details/113841064
func DeduplicateFilters ¶ added in v0.19.0
筛选条件去重
func LoadOrStore ¶ added in v0.19.0
从配置中读取值,如果不存在则写入
func LoggerConvertor ¶ added in v0.19.0
func LoggerConvertor(f group.HandlerFunc) gin.HandlerFunc
func PatchUserBan ¶ added in v0.15.0
func PatchUserName ¶ added in v0.15.0
func PatchUserNickname ¶ added in v0.15.0
func PatchUserRole ¶ added in v0.15.0
Types ¶
type Condition ¶ added in v0.19.0
type Condition struct { // 是否包含转发 Reply bool `json:"reply" form:"reply"` // 是否包含评论 Comments bool `json:"comments" form:"comments"` // 查询排列顺序 Order string `json:"order" form:"order"` // 查询行数 Limit int `json:"limit" form:"limit"` // 查询偏移 Offset int `json:"offset" form:"offset"` // 其他条件 Conds []string `json:"conds" form:"conds"` }
查询条件
type Config ¶ added in v0.19.0
type Config struct { Filename string `toml:"-" yaml:"-" json:"-"` // 配置文件保存路径 Path Path `toml:"path" yaml:"path" json:"path"` // 各文件路径 Server Server `toml:"server" yaml:"server" json:"server"` // 服务器参数 Role Role `toml:"role" yaml:"role" json:"role "` // 权限组 Extra map[string]any `toml:"extra" yaml:"extra" json:"extra"` // 额外项 }
webhook 配置
func (*Config) AfterInitial ¶ added in v0.19.0
func (c *Config) AfterInitial()
type Path ¶ added in v0.19.0
type Path struct { Root string `toml:"root" yaml:"root" json:"root" default:"resource"` // 程序根目录 Logs string `toml:"logs" yaml:"logs" json:"logs" default:"logs" join:"Root"` // 记录文件夹 UserDB string `toml:"userDB" yaml:"userDB" json:"userDB" default:"users.db" join:"Root"` // 用户数据库文件 BlogDB string `toml:"blogDB" yaml:"blogDB" json:"blogDB" default:"blogs.db" join:"Root"` // 博文数据库文件 Public string `toml:"public" yaml:"public" json:"public" default:"public" join:"Root"` // 公开文件夹 Backup string `toml:"backup" yaml:"backup" json:"backup" default:"backup" join:"Public"` // 博文数据库备份文件夹 Upload string `toml:"upload" yaml:"upload" json:"upload" default:"upload" join:"Public"` // 上传文件文件夹 Full *Path `toml:"-" yaml:"-" json:"-"` // 以上字段的全路径 通过 utils.NewJoin 函数拼接 }
func (*Path) AfterInitial ¶ added in v0.19.0
func (*Path) CopyBlogDB ¶ added in v0.19.0
func (p *Path) CopyBlogDB()
type Server ¶ added in v0.19.0
type UserClaims ¶ added in v0.15.0
用户声明
func (UserClaims) TableName ¶ added in v0.17.3
func (UserClaims) TableName() string
func (UserClaims) Token ¶ added in v0.15.0
func (c UserClaims) Token() (string, error)
func (UserClaims) Valid ¶ added in v0.15.0
func (c UserClaims) Valid() error
Click to show internal directories.
Click to hide internal directories.