middleware

package
v0.0.0-...-70261f9 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2023 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CasbinHandler

func CasbinHandler() gin.HandlerFunc

CasbinHandler 拦截器

func Cors

func Cors() gin.HandlerFunc

Cors 直接放行所有跨域请求并放行所有 OPTIONS 方法

func DefaultCheckOrMark

func DefaultCheckOrMark(key string, expire int, limit int) (err error)

func DefaultGenerationKey

func DefaultGenerationKey(c *gin.Context) string

DefaultGenerationKey 默认生成key

func DefaultLimit

func DefaultLimit() gin.HandlerFunc

func GinLogger

func GinLogger() gin.HandlerFunc

GinLogger 用于替换gin框架的Logger中间件,不传参数,直接这样写

func GinRecovery

func GinRecovery(stack bool) gin.HandlerFunc

GinRecovery recover掉项目可能出现的panic,并使用zap记录相关日志

func JwtToken

func JwtToken(isNeed bool) gin.HandlerFunc

JwtToken jwt中间件

func LoadTls

func LoadTls() gin.HandlerFunc

func NeedInit

func NeedInit() gin.HandlerFunc

处理跨域请求,支持options访问

func OperationRecord

func OperationRecord() gin.HandlerFunc

func SetLimitWithTime

func SetLimitWithTime(key string, limit int, expiration time.Duration) error

SetLimitWithTime 设置访问次数

Types

type LimitConfig

type LimitConfig struct {
	// GenerationKey 根据业务生成key 下面CheckOrMark查询生成
	GenerationKey func(c *gin.Context) string
	// 检查函数,用户可修改具体逻辑,更加灵活
	CheckOrMark func(key string, expire int, limit int) error
	// Expire key 过期时间
	Expire int
	// Limit 周期时间
	Limit int
}

func (LimitConfig) LimitWithTime

func (l LimitConfig) LimitWithTime() gin.HandlerFunc

Jump to

Keyboard shortcuts

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