web_middleware

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CorsMiddleware

func CorsMiddleware() gin.HandlerFunc

CorsMiddleware 跨域中间件

func GinLogger

func GinLogger() gin.HandlerFunc

GinLogger gin 日志请求中间件

func IPFilterMiddleware

func IPFilterMiddleware(maxRequestsPerIP int, timeWindow time.Duration) gin.HandlerFunc

IPFilterMiddleware 中间件用于过滤IP并限制请求频率 maxRequestsPerIP ip请求阈值 example:200 timeWindow 统计时间 example: 1*time.Minute

func IPFilterWithRedisMiddleware

func IPFilterWithRedisMiddleware(redisClient *redis.Client, maxRequestsPerIP int, timeWindow time.Duration) gin.HandlerFunc

IPFilterWithRedisMiddleware 中间件用于过滤IP并限制请求频率(redis)

func RequestIDMiddleware

func RequestIDMiddleware() gin.HandlerFunc

RequestIDMiddleware requestID请求中间件

func TimeoutMiddleware

func TimeoutMiddleware(reqTimeout time.Duration) gin.HandlerFunc

TimeoutMiddleware 接口超时中间件

func TimeoutResponse

func TimeoutResponse(c *gin.Context)

TimeoutResponse 超时响应

Types

type IPCounter

type IPCounter struct {
	Count      int       // Count ip计数
	LastAccess time.Time // LastAccess 请求时间
}

IPCounter 用于记录IP请求计数和时间

type IPCounterWithRedis

type IPCounterWithRedis struct {
	Count      int       // Count ip计数
	LastAccess time.Time // LastAccess 请求时间
}

IPCounterWithRedis 用于记录IP请求计数和时间

Jump to

Keyboard shortcuts

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