Expand description
Tower middleware helpers.
Re-exports§
pub use crate::context::ClientKind;pub use crate::context::IdentityExtractor;pub use crate::context::RequestContext;pub use crate::context::RequestIdentity;pub use crate::context::api_key_identity;pub use crate::context::client_ip_identity;pub use crate::context::context_identity;pub use crate::context::trusted_proxy_client_ip_identity;
Structs§
- ApiDefaults
- High-level configurable API defaults built from explicit Axum/Tower primitives.
- Body
Limit Layer - Tower layer that rejects requests with a declared oversized body.
- Body
Limit Service - Service produced by
BodyLimitLayer. - Catch
Panic Layer - Tower layer that catches panics from the inner service.
- Catch
Panic Service - Service produced by
CatchPanicLayer. - InMemory
Rate Limit Store - In-memory rate-limit store intended for local development and single-process apps.
- Metrics
Layer - Tower layer that invokes
HttpMetricsHookfor request lifecycle metrics. - Metrics
Service - Service produced by
MetricsLayer. - Prometheus
Metrics - In-memory Prometheus-format HTTP metrics collector.
- Rate
Limit Config - Typed config for production-shaped rate limiting.
- Rate
Limit Decision - Decision returned by a rate-limit store.
- Rate
Limit Error - Error returned by rate-limit stores.
- Rate
Limit Layer - Tower layer that applies configured rate limiting.
- Rate
Limit Service - Service produced by
RateLimitLayer. - Request
Context Layer - Tower layer that inserts request/correlation context into request extensions.
- Request
Context Service - Service produced by
RequestContextLayer. - Request
IdConfig - Typed configuration for validated request ID propagation.
- Request
IdLayer - Legacy Tower layer that adds an
x-request-idresponse header when absent. - Request
IdService - Service produced by
RequestIdLayer. - Request
Scope Layer - Tower layer that creates one dependency request scope per HTTP request.
- Request
Scope Service - Service produced by
RequestScopeLayer. - Route
Make Span - Span maker that records request method, URI, and a stable route label.
- Security
Headers Layer - Tower layer that adds conservative API security headers to responses.
- Security
Headers Service - Service produced by
SecurityHeadersLayer. - Timeout
Response Layer - Tower layer that maps elapsed inner work to an HTTP timeout response.
- Timeout
Response Service - Service produced by
TimeoutResponseLayer. - Validated
Request IdLayer - Tower layer that validates, generates, stores, and propagates request IDs.
- Validated
Request IdService - Service produced by
ValidatedRequestIdLayer.
Enums§
- Request
IdMode - Request ID validation behavior for inbound
x-request-idvalues.
Traits§
- Http
Metrics Hook - Backend-neutral hook for recording HTTP request metrics.
- Rate
Limit Store - Store adapter used by rate-limit layers.
Functions§
- body_
limit_ layer - Creates a request body limit layer using the declared
Content-Length. - catch_
panic_ layer - Creates a layer that catches panics from the inner service and maps them to a
500 Internal Server Errorresponse. - compression_
layer - Creates a gzip response compression layer.
- cors_
layer - Creates a permissive CORS layer for API development and examples.
- cors_
origin_ layer - Creates a CORS layer for a single explicit API origin.
- metrics_
layer - Creates a metrics hook layer without a stable route label.
- rate_
limit_ layer - Creates a Tower rate limit layer.
- request_
context_ layer - Creates a Tower layer that enriches
RequestContextrequest extensions. - request_
id_ layer - Creates the legacy response-only request-id layer.
- request_
scope_ layer - Creates a request-scope layer backed by a shared dependency container.
- route_
metrics_ layer - Creates a metrics hook layer that records a stable route label.
- route_
trace_ layer - Creates an HTTP tracing layer that records a stable route label.
- security_
headers_ layer - Creates a layer that applies conservative API security headers.
- streaming_
body_ limit_ layer - Creates a streaming request body limit layer.
- timeout_
layer - Creates a Tower timeout layer.
- timeout_
response_ layer - Creates a timeout layer that maps elapsed inner work to
408 Request Timeout. - trace_
layer - Creates an HTTP tracing layer for requests and responses.
- validated_
request_ id_ layer - Creates a validated request ID layer.
- webhook_
body_ limit_ layer - Creates a request body limit layer for webhook/raw-body routes.
Type Aliases§
- Request
IdPolicy - Compatibility alias for naming request ID validation policy.