common

package
v3.34.0 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: AGPL-3.0 Imports: 23 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SecretKey []byte

Functions

func CanAccess added in v3.5.1

func CanAccess(user *model.User, meta *model.Meta, reqPath string, password string) bool

func CanWrite added in v3.5.1

func CanWrite(meta *model.Meta, path string) bool

func ErrorResp

func ErrorResp(c *gin.Context, err error, code int, l ...bool)

ErrorResp is used to return error response @param l: if true, log error

func ErrorStrResp

func ErrorStrResp(c *gin.Context, str string, code int, l ...bool)

func ErrorWithDataResp added in v3.5.1

func ErrorWithDataResp(c *gin.Context, err error, code int, data interface{}, l ...bool)

func GenerateToken

func GenerateToken(user *model.User) (tokenString string, err error)

func GetApiUrl

func GetApiUrl(r *http.Request) string

func IsApply added in v3.13.0

func IsApply(metaPath, reqPath string, applySub bool) bool

func IsStorageSignEnabled added in v3.15.0

func IsStorageSignEnabled(rawPath string) bool

func Proxy

func Proxy(w http.ResponseWriter, r *http.Request, link *model.Link, file model.Obj) error

func ShouldProxy added in v3.14.0

func ShouldProxy(storage driver.Driver, filename string) bool

ShouldProxy TODO need optimize when should be proxy? 1. config.MustProxy() 2. storage.WebProxy 3. proxy_types

func Sign

func Sign(obj model.Obj, parent string, encrypt bool) string

func SuccessResp

func SuccessResp(c *gin.Context, data ...interface{})

Types

type PageResp

type PageResp struct {
	Content interface{} `json:"content"`
	Total   int64       `json:"total"`
}

type Resp

type Resp[T any] struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
	Data    T      `json:"data"`
}

type UserClaims

type UserClaims struct {
	Username string `json:"username"`
	PwdTS    int64  `json:"pwd_ts"`
	jwt.RegisteredClaims
}

func ParseToken

func ParseToken(tokenString string) (*UserClaims, error)

Jump to

Keyboard shortcuts

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