Expand description
Built-in middleware helpers for common cross-cutting concerns.
Provides pre-configured CORS and request-ID layers, plus re-exports of Axum’s middleware combinators.
Modules§
- future
- Future types.
Structs§
- AddExtension
- Middleware for adding some shareable value to request extensions.
- Cors
Config - Configuration for the CORS middleware.
- From
Extractor - Middleware that runs an extractor and discards the value.
- From
Extractor Layer Layerthat appliesFromExtractorthat runs an extractor and discards the value.- FromFn
- A middleware created from an async function.
- From
FnLayer - A
tower::Layerfrom an async function. - MapRequest
- A middleware created from an async function that transforms a request.
- MapRequest
Layer - A
tower::Layerfrom an async function that transforms a request. - MapResponse
- A middleware created from an async function that transforms a response.
- MapResponse
Layer - A
tower::Layerfrom an async function that transforms a response. - Next
- The remainder of a middleware stack, including the handler.
- Response
Axum Body - Service generated by
ResponseAxumBodyLayer. - Response
Axum Body Future - Response future for
ResponseAxumBody. - Response
Axum Body Layer - Layer that transforms the Response body to
crate::body::Body. - Uuid
Request Id - UUID v4 request ID generator.
Statics§
- X_
REQUEST_ ID - Header name used for request IDs.
Traits§
- Into
MapRequest Result - Trait implemented by types that can be returned from
map_request,map_request_with_state.
Functions§
- cache_
control - Returns a layer that sets the
Cache-Controlresponse header if not already present. - cors
- Returns a CORS layer with permissive defaults suitable for development.
- cors_
with_ config - Returns a CORS layer configured according to the given
CorsConfig. - from_
extractor - Create a middleware from an extractor.
- from_
extractor_ with_ state - Create a middleware from an extractor with the given state.
- from_fn
- Create a middleware from an async function.
- from_
fn_ with_ state - Create a middleware from an async function with the given state.
- map_
request - Create a middleware from an async function that transforms a request.
- map_
request_ with_ state - Create a middleware from an async function that transforms a request, with the given state.
- map_
response - Create a middleware from an async function that transforms a response.
- map_
response_ with_ state - Create a middleware from an async function that transforms a response, with the given state.
- no_
cache - Returns a layer that sets
Cache-Control: no-cache, no-store, must-revalidateif the response does not already include aCache-Controlheader. - no_
store - Returns a layer that sets
Cache-Control: no-storeif the response does not already include aCache-Controlheader. - request_
id - Returns a tuple of layers that set and propagate an
x-request-idheader. - timeout
- Returns a layer that fails requests which are not completed within the
given
duration.