Documentation ¶
Overview ¶
Package ratelimit provides a basic rate limiter middleware for net/http.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Handler ¶
type Handler struct { // Limiter is the rate limiter used to limit requests. Limiter *rate.Limiter // SetRetryAfter sets the Retry-After header on rate limited // responses. If false, the header is not set. SetRetryAfter bool // SetXLimit sets the X-RateLimit-* headers on rate limited SetXLimit bool // OnLimit is called when a request is rate limited. // If nil, http.StatusTooManyRequests (429) is returned. OnLimit func(w http.ResponseWriter, r *http.Request) // Next is the Next handler in the chain. Next http.HandlerFunc }
Handler is a net/http middleware that rate limits requests based on the configured limiter.
Click to show internal directories.
Click to hide internal directories.