Documentation
¶
Index ¶
Constants ¶
View Source
const RequestIDKey contextKey = "request_id"
Variables ¶
This section is empty.
Functions ¶
func GetRequestID ¶
Types ¶
type RateLimiter ¶
type RateLimiter struct {
// contains filtered or unexported fields
}
RateLimiter is a simple in-memory fixed-window limiter keyed by a function of the request (client IP by default). It bounds token-exchange / token-mint abuse. In a multi-replica deployment this is per-process; back it with a shared store (e.g. Redis) for a global limit — documented as a known limitation.
func NewRateLimiter ¶
func NewRateLimiter(limit int, interval time.Duration, keyFn func(*http.Request) string) *RateLimiter
NewRateLimiter allows up to limit requests per interval per key.
func (*RateLimiter) Middleware ¶
func (rl *RateLimiter) Middleware(next http.Handler) http.Handler
Middleware enforces the limit, returning 429 when exceeded.
Click to show internal directories.
Click to hide internal directories.