Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Limiter ¶
type Limiter struct {
// contains filtered or unexported fields
}
Limiter implements a per-IP token bucket rate limiter.
func New ¶
New creates a rate limiter allowing rate tokens per second with the given burst capacity.
func (*Limiter) Allow ¶
Allow consumes one token for the given IP and reports whether the request is allowed.
func (*Limiter) Middleware ¶
Middleware wraps an http.Handler and rejects requests that exceed the rate limit with a 429 status code.
Click to show internal directories.
Click to hide internal directories.