Expand description
Keyed HTTP rate limiting middleware for Tower.
The crate is Tower-first: the core interfaces do not require Axum, Tokio, Redis, or a particular request identity policy. Optional adapters are enabled through Cargo features.
Structs§
- Client
IpKey Extractor - Extract a client IP key from supported client-IP headers, falling back to the socket IP.
- Default
Response Factory - The default empty-body response factory.
- IpKey
Extractor - Extract an IP client key from only the socket peer.
- Memory
Store - In-process Store whose clones share one counter set.
- Policy
- A policy’s rate-limit state exposed to a downstream handler.
- Rate
Limit - Tower service produced by
super::RateLimitLayer. - Rate
Limit Builder - Builder for a rate-limit layer with compile-time store/resolver/factory types.
- Rate
Limit Context - Read-only rate-limit state carried in request extensions for allowed requests.
- Rate
Limit Layer - Layer that applies
RateLimit. - Redis
Store - Redis-backed implementation of the common fixed-window
Storeseam. - Response
Future - Response future for
super::RateLimit. - Trusted
Proxy Client IpKey Extractor - Extract a client IP key only when the socket peer satisfies an application trust policy.
- Usage
- The usage and reset duration returned by a store.
Enums§
- Config
Error - Errors produced while validating a rate-limit builder.
- Memory
Store Error - Errors returned by the in-memory rate limit store.
- Rate
Limit Error - A failure produced while resolving or charging a rate-limit policy.
- Rate
Limit Fields - The Rate Limit Fields revision emitted in responses.
- Redis
Store Error - Errors returned by the Redis rate-limit store.
- Response
Reason - The structured reason passed to a
ResponseFactory. - Store
Failure Mode - The operating mode to use when the rate-limit store fails.
Traits§
- KeyExtractor
- Extract a client key synchronously from a request.
- Limit
Provider - Resolve a fixed or request-derived quota limit asynchronously.
- Response
Factory - A factory for responses to rate-limit middleware results.
- Store
- An asynchronous fixed-window rate-limit store.