middleware

package
v0.0.0-...-dbb23d3 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const RequestIDKey requestIDCtxKey = "requestIDCtxKey"

RequestIDKey 为 RequestID 在 Context 中的 Key

Variables

View Source
var RequestIDHeader = "X-Request-Id"

RequestIDHeader 为 response 中表示 request id 的 HTTP header

Functions

func BurstBucketLimiter

func BurstBucketLimiter(limit int, interval time.Duration) chu.Middleware

BurstBucketLimiter 应对突发高频率请求的限流 limit: 突发最大并发数量 interval: bucket 每填充一个 token 的时间间隔

func CorsMiddleware

func CorsMiddleware(next http.Handler) http.Handler

CorsMiddleware 跨域中间件 TODO

func GetRequestID

func GetRequestID(c context.Context) string

GetRequestID 从 Context 中获取 RequestID

func Limiter

func Limiter(limit int) chu.Middleware

Limiter 限流中间件(限制同时可以处理的请求数量)

func LogMiddleware

func LogMiddleware(next http.Handler) http.Handler

LogMiddleware 日志中间件 TODO

func RequestID

func RequestID(next http.Handler) http.Handler

RequestID 记录请求 ID

func Timeout

func Timeout(timeout time.Duration) chu.Middleware

Timeout 超时中间件

Types

This section is empty.

Jump to

Keyboard shortcuts

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