Expand description
Request ID middleware — assigns a unique ID to each request.
The ID is available via the RequestId extractor and is also
set as the x-request-id response header.
§Example
ⓘ
use typeway_server::request_id::{RequestId, RequestIdLayer};
Server::<API>::new(handlers)
.layer(RequestIdLayer::new())
.serve(addr)
.await?;
// In handlers:
async fn handler(Extension(id): Extension<RequestId>) -> String {
format!("request: {}", id.0)
}Structs§
- Request
Id - A unique request identifier.
- Request
IdLayer - Tower layer that assigns a unique
x-request-idto each request. - Request
IdService - The service produced by
RequestIdLayer.