middleware

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2024 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetLeakyRateLimitMiddleware

func GetLeakyRateLimitMiddleware(qps int) func(ctx *gin.Context)

GetLeakyRateLimitMiddleware 漏斗算法

func GetRecoverMiddleware

func GetRecoverMiddleware(errorResponse interface{}) func(ctx *gin.Context)

func GetTokenRateLimitMiddleware

func GetTokenRateLimitMiddleware(qps int, errorResponse interface{}) func(ctx *gin.Context)

GetTokenRateLimitMiddleware 令牌桶算法

func Logging

func Logging() gin.HandlerFunc

Logging is a middleware function that logs the each request.

func Mock

func Mock(c *gin.Context)

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

func NoCache(c *gin.Context)

NoCache is a middleware function that appends headers to prevent the client from caching the HTTP response.

func Options

func Options(c *gin.Context)

Options is a middleware function that appends headers for options requests and aborts then exits the middleware chain and ends the request.

func Secure

func Secure(c *gin.Context)

Secure is a middleware function that appends security and resource access headers.

Types

This section is empty.

Jump to

Keyboard shortcuts

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