Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type RateLimiter ¶
type RateLimiter struct {
// contains filtered or unexported fields
}
RateLimiter provides per-key rate limiting.
func NewRateLimiter ¶
func NewRateLimiter(rps float64, burst int) *RateLimiter
NewRateLimiter creates a new rate limiter with a cleanup goroutine.
func (*RateLimiter) Close ¶
func (rl *RateLimiter) Close()
Close stops the cleanup goroutine. Safe to call multiple times.
func (*RateLimiter) Middleware ¶
func (rl *RateLimiter) Middleware() func(http.Handler) http.Handler
Middleware returns a rate limiting middleware. Always rate limits by IP address to prevent key manipulation attacks.
Click to show internal directories.
Click to hide internal directories.