controller

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: May 31, 2023 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const ERR_OK = 0
View Source
const EnableProxyLog = true

Variables

This section is empty.

Functions

This section is empty.

Types

type APIHandler

type APIHandler struct {
	WhiteList *serverdb.WhiteList
	// TokenService *token.Token
	DB *gorm.DB
}

APIHandler 是所有API的处理器

func NewAPIHandler

func NewAPIHandler(
	api_secret string,
	token_lifespan uint32,
	dialector string,
	connection_str string,
	verbose bool,
) (*APIHandler, *gin.Engine)

// NewAPIHandler 创建APIHandler实例

func (*APIHandler) RegisterRoutes

func (h *APIHandler) RegisterRoutes(router *gin.Engine, routes *[]config.ProxyRoute)

RegisterRoutes 注册路由

func (*APIHandler) Response

func (h *APIHandler) Response(ctx *gin.Context, msg string, biz_code ErrorCode, body gin.H)

通用API响应

func (*APIHandler) ResponseRaw

func (h *APIHandler) ResponseRaw(ctx *gin.Context, msg string, biz_code ErrorCode, body gin.H, code int)

func (*APIHandler) VerifyUser

func (h *APIHandler) VerifyUser() gin.HandlerFunc

type ErrorCode

type ErrorCode uint32
const (
	ERR_INVALID_PARAMETERS ErrorCode = iota + 1000
	ERR_INVALID_USER
	ERR_INVALID_TOKEN
	ERR_INVALID_USER_ID
	ERR_TOKEN_EXPIRED
	ERR_TOKEN_GENERATE_FAILED
	ERR_DATA_PERSISTENCE
	ERR_REGISTER_FAILED
	ERR_SENDEMAIL_FAILED
	ERR_ACTIVIATE_FAILED
	ERR_DEACTIVIATE_FAILED
	ERR_GENERATE_TOKEN_FAILED
	ERR_UNKNOWN_FAILED
)

Jump to

Keyboard shortcuts

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