middleware

package
v0.0.0-...-38e5134 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2022 License: MIT Imports: 26 Imported by: 0

Documentation

Overview

Package middleware @program: arco-design-pro-gin @author: [lliuhuan](https://github.com/lliuhuan) @create: 2021-12-10 14:14

Package middleware @program: arco-design-pro-gin @author: [lliuhuan](https://github.com/lliuhuan) @create: 2021-12-10 14:31

Package middleware @program: arco-design-pro-gin @author: [lliuhuan](https://github.com/lliuhuan) @create: 2021-12-10 14:35

Package middleware @program: arco-design-pro-gin @author: [lliuhuan](https://github.com/lliuhuan) @create: 2021-12-10 14:13

Package middleware @program: arco-design-pro-gin @author: [lliuhuan](https://github.com/lliuhuan) @create: 2021-12-10 14:28

Package middleware @program: arco-design-pro-gin @author: [lliuhuan](https://github.com/lliuhuan) @create: 2021-12-10 14:20

Package middleware @program: arco-design-pro-gin @author: [lliuhuan](https://github.com/lliuhuan) @create: 2021-12-10 14:18

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 DefaultLogger

func DefaultLogger() gin.HandlerFunc

func GinLogger

func GinLogger() gin.HandlerFunc

GinLogger 接收gin框架默认的日志

func GinRecovery

func GinRecovery(stack bool) gin.HandlerFunc

GinRecovery recover掉项目可能出现的panic

func IpVerifyMiddleware

func IpVerifyMiddleware() gin.HandlerFunc

IpVerifyMiddleware IP限流

func JWTAuth

func JWTAuth() gin.HandlerFunc

func LoadTls

func LoadTls() gin.HandlerFunc

LoadTls https

func OperationRecord

func OperationRecord() gin.HandlerFunc

func RateLimitMiddleware

func RateLimitMiddleware(fillInterval time.Duration) gin.HandlerFunc

RateLimitMiddleware 令牌桶限流

func SetLimitWithTime

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

SetLimitWithTime 设置访问次数

func TimeoutMiddleware

func TimeoutMiddleware(timeout time.Duration) func(c *gin.Context)

TimeoutMiddleware gin 请求超时处理

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

type LogLayout

type LogLayout struct {
	Time      time.Time
	Metadata  map[string]interface{} // 存储自定义原数据
	Path      string                 // 访问路径
	Query     string                 // 携带query
	Body      string                 // 携带body数据
	IP        string                 // ip地址
	UserAgent string                 // 代理
	Error     string                 // 错误
	Cost      time.Duration          // 花费时间
	Source    string                 // 来源
}

LogLayout 日志layout

type Logger

type Logger struct {
	// Filter 用户自定义过滤
	Filter func(c *gin.Context) bool
	// FilterKeyword 关键字过滤(key)
	FilterKeyword func(layout *LogLayout) bool
	// AuthProcess 鉴权处理
	AuthProcess func(c *gin.Context, layout *LogLayout)
	// 日志处理
	Print func(LogLayout)
	// Source 服务唯一标识
	Source string
}

func (Logger) SetLoggerMiddleware

func (l Logger) SetLoggerMiddleware() gin.HandlerFunc

Jump to

Keyboard shortcuts

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