Documentation
¶
Overview ¶
Package ratelimit limits requests per key (token, user, IP) with GCRA, a smooth token bucket that needs one timestamp per key. The memory store fits one process; drivers/redis provides a shared one (BETA).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ByToken ¶
ByToken keys requests by bearer token (hashed, never stored in clear), falling back to the client IP.
func Middleware ¶
Middleware limits requests with l, keyed by key (ByToken when nil). It sets RateLimit-Limit/Remaining/Reset on every response and answers 429 with Retry-After when the bucket is empty. A failing limiter denies the request (fail closed).
Types ¶
Click to show internal directories.
Click to hide internal directories.