Expand description
Identity-aware rate limiting middleware.
Requests are keyed by authenticated identity (API key ID or user ID) when available, falling back to the client IP address. Each key gets a fixed-window counter that resets every 60 seconds.
Responses carry standard rate-limit headers:
X-RateLimit-Limit– maximum requests allowed per windowX-RateLimit-Remaining– requests left in the current windowX-RateLimit-Reset– epoch timestamp when the window resets
API keys with a rate_limit_override use that value instead of the
server-wide default.
Structs§
- Rate
Limit Context - Context needed by the rate limit middleware.
- Rate
Limit State - Shared rate limiter state with fixed-window counters.
Enums§
- Rate
Limit Key - Rate limit key: identity-based when authenticated, IP-based otherwise.
Functions§
- per_
minute - Build a per-identity rate limiter allowing
requests_per_minuterequests per minute. - rate_
limit - Axum middleware that enforces identity-aware rate limiting.