middleware

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AccessToken = "AccessToken"
)

Variables

View Source
var (
	// ErrTokenEmpty token 为空
	ErrTokenEmpty = errors.New("token is empty")
	// ErrTokenInvalid token 无效
	ErrTokenInvalid = errors.New("token is invalid")
)

Functions

func AesAuth

func AesAuth(config *AesAuthConfig) func(c *gin.Context)

AesAuth 鉴权中间件

func Logger

func Logger() gin.HandlerFunc

func NewCors

func NewCors(configs ...cors.Config) gin.HandlerFunc

NewCors returns a CORS middleware.

func Prometheus

func Prometheus() gin.HandlerFunc

Prometheus 响应时间统计中间件

func Recover

func Recover() gin.HandlerFunc

Recover is a middleware that recovers from any panics and writes a 500 if there was one.

Types

type AesAuthConfig

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

AesAuthConfig 鉴权中间件配置

func NewAesAuthConfig

func NewAesAuthConfig(cipherInstance cipher.AesInterface, opts ...Option) *AesAuthConfig

NewAesAuthConfig 鉴权中间件配置

type Option

type Option func(*AesAuthConfig)

func WithCheckToken

func WithCheckToken(checkToken func(token []byte) bool) Option

WithCheckToken 设置校验 token

func WithResp

func WithResp(resp response.Interface) Option

WithResp 设置响应

Jump to

Keyboard shortcuts

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