Documentation ¶
Index ¶
- func GetLeakyRateLimitMiddleware(qps int) func(ctx *gin.Context)
- func GetRecoverMiddleware(errorResponse interface{}) func(ctx *gin.Context)
- func GetTokenRateLimitMiddleware(qps int, errorResponse interface{}) func(ctx *gin.Context)
- func Logging() gin.HandlerFunc
- func Mock(c *gin.Context)
- func NoCache(c *gin.Context)
- func Options(c *gin.Context)
- func Secure(c *gin.Context)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetLeakyRateLimitMiddleware ¶
GetLeakyRateLimitMiddleware 漏斗算法
func GetRecoverMiddleware ¶
func GetTokenRateLimitMiddleware ¶
GetTokenRateLimitMiddleware 令牌桶算法
func Logging ¶
func Logging() gin.HandlerFunc
Logging is a middleware function that logs the each request.
func Mock ¶
Mock mock中间件 调用过程:首先gin要使用这个中间件,会把param中的test_traffic开头的请求参数都设置到gin的ctx中。 然后service方法在发起对依赖服务的http请求时,可以设置相对应的mock参数,然后真正请求时,会将这个依赖服务对应的mock参数与ctx中存储的test_traffic请求参数进行比对, 如果ctx中存储的test_traffic请求参数包含这个依赖服务对应的mock参数,则进行url的替换,会请求至B端的yapi mock平台,获取提前配置好的mock结果。
func NoCache ¶
NoCache is a middleware function that appends headers to prevent the client from caching the HTTP response.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.