checker

package
v5.3.3-pre13 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2024 License: AGPL-3.0 Imports: 10 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	//BackendUploadPath 后台上传网址路径
	BackendUploadPath = `/manager/upload`
	//FrontendUploadPath 前台上传网址路径
	FrontendUploadPath = `/user/file/upload`
	//SetURLParamDefaultValue 设置参数默认值
	SetURLParamDefaultValue func(*url.Values)
)
View Source
var DefaultNoCheck = func(ctx echo.Context) (subdir string, name string, err error) {
	subdir = time.Now().Format(`2006/01/02/`)
	return
}

DefaultNoCheck 默认 Checker

View Source
var DefaultWithVerify = func(ctx echo.Context) (subdir string, name string, err error) {
	timestamp := ctx.Formx(`time`).Int64()

	token := Token(ctx.Queries())
	if ctx.Form(`token`) != token {

		err = ctx.NewError(code.InvalidParameter, `令牌错误`)
		return
	}
	if time.Now().Unix()-timestamp > UploadURLMaxAge {
		err = ctx.NewError(code.DataHasExpired, `上传网址已过期`)
		return
	}
	return DefaultNoCheck(ctx)
}
View Source
var UploadURLMaxAge int64 = 86400

UploadURLMaxAge 上传链接生存时间

Functions

func BackendURL

func BackendURL() string

BackendURL 后台网址

func BackendUploadURL

func BackendUploadURL(subdir string, values ...interface{}) string

BackendUploadURL 构建后台上传网址

func FrontendURL

func FrontendURL() string

FrontendURL 前台网址

func FrontendUploadURL

func FrontendUploadURL(subdir string, values ...interface{}) string

FrontendUploadURL 构建前台上传网址

func Token

func Token(values ...interface{}) string

Token 生成签名

func URLParam

func URLParam(subdir string, values ...interface{}) string

URLParam URLParam(`refid`,123)

Types

type APIKey

type APIKey interface {
	APIKey() string
}

APIKey API Key

type Checker

type Checker func(echo.Context) (subdir string, name string, err error)

Checker 验证并生成子文件夹名称和文件名称

Jump to

Keyboard shortcuts

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