middleware

package
v0.0.0-...-31439ab Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2024 License: GPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const CubeProHeaderKey = "x-cubing-pro"
View Source
const IdentityKey = "UserDetail"

Variables

This section is empty.

Functions

func CacheMiddleware

func CacheMiddleware(cacheDuration time.Duration) gin.HandlerFunc

CacheMiddleware 缓存中间件

func CheckAuthMiddlewareFunc

func CheckAuthMiddlewareFunc(auth user2.Auth) gin.HandlerFunc

func CheckHeaderMiddleware

func CheckHeaderMiddleware(ctx *gin.Context)

func ClearCheckAuth

func ClearCheckAuth()

func Code

func Code() *code

func CorsMiddleware

func CorsMiddleware() gin.HandlerFunc

func GenerateCacheKey

func GenerateCacheKey(c *gin.Context) (string, error)

GenerateCacheKey 根据请求生成一个唯一的缓存键

func GetAuthUser

func GetAuthUser(ctx *gin.Context) (user2.User, error)

func InitCheckAuth

func InitCheckAuth(svc *svc.Svc)

func NewStatusCodeGreaterThan

func NewStatusCodeGreaterThan(code int) gin.HandlerFunc

func RateLimitMiddleware

func RateLimitMiddleware(limit int, duration time.Duration) gin.HandlerFunc

Types

type CacheEntry

type CacheEntry struct {
	ResponseBody []byte
	CreatedAt    time.Time
}

CacheEntry 存储缓存的响应内容及其创建时间

type CheckAuth

type CheckAuth struct {
	// contains filtered or unexported fields
}

type CodeResp

type CodeResp struct {
	Id    string    `json:"id"`
	Image string    `json:"image"`
	Ext   time.Time `json:"ext"`
}

type Jwt

type Jwt struct {
	*jwt.GinJWTMiddleware
	// contains filtered or unexported fields
}

func InitJWT

func InitJWT(svc *svc.Svc) *Jwt

func JWT

func JWT() *Jwt

type JwtMapClaims

type JwtMapClaims struct {
	Id           uint       `json:"id"`
	Auth         user2.Auth `json:"auth"`
	Name         string     `json:"name"`
	EnName       string     `json:"enName"`
	LoginID      string     `json:"loginID"`
	CubeID       string     `json:"cubeID"`
	WcaID        string     `json:"wcaID"`
	DelegateName string     `json:"delegateName"`
}

func GetJwtUser

func GetJwtUser(ctx *gin.Context) (JwtMapClaims, error)

type LoginRequest

type LoginRequest struct {
	// 登录信息
	LoginID   string `json:"loginID"`  // 登录用的ID, email, phone, QQ等,
	Password  string `json:"password"` // 密码(加密后)
	TimeStamp int64  `json:"timestamp"`
	// 验证码
	VerifyId    string `json:"verifyId"`
	VerifyValue string `json:"verifyValue"`
}

type RateLimitMiddlewareRequestInfo

type RateLimitMiddlewareRequestInfo struct {
	// contains filtered or unexported fields
}

type ResponseRecorder

type ResponseRecorder struct {
	gin.ResponseWriter
	Writer io.Writer
}

ResponseRecorder 捕获 gin 响应的自定义 writer

func (*ResponseRecorder) Write

func (w *ResponseRecorder) Write(data []byte) (int, error)

Write 捕获响应数据

type VerifyCodeReq

type VerifyCodeReq struct {
	// 验证码
	VerifyId    string `query:"verifyId"`
	VerifyValue string `query:"verifyValue"`
}

Jump to

Keyboard shortcuts

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