Documentation ¶
Index ¶
- Constants
- Variables
- func BurstBucketLimiter(limit int, interval time.Duration) chu.Middleware
- func CorsMiddleware(next http.Handler) http.Handler
- func GetRequestID(c context.Context) string
- func Limiter(limit int) chu.Middleware
- func LogMiddleware(next http.Handler) http.Handler
- func RequestID(next http.Handler) http.Handler
- func Timeout(timeout time.Duration) chu.Middleware
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 GetRequestID ¶
GetRequestID 从 Context 中获取 RequestID
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.