Expand description
Actix Web middleware for generating and managing request UUIDs
This crate generates a unique UUID for each HTTP request and adds it to the response headers. It also maintains the UUID in globally accessible thread-local variables during request processing.
§Usage Example
use actix_web::{App, HttpServer, web};
use actix_web_request_uuid::RequestIDMiddleware;
#[actix_web::main]
async fn main() -> std::io::Result<()> {
HttpServer::new(|| {
App::new()
.wrap(RequestIDMiddleware::new())
.service(web::resource("/").to(|| async { "Hello world!" }))
})
.bind("127.0.0.1:8080")?
.run()
.await
}
Structs§
- RequestID
- A struct representing a request ID
- RequestID
Middleware - Middleware for generating and managing request IDs
- RequestID
Service - Service that handles request IDs
Constants§
- DEFAULT_
ID_ LENGTH - Default ID length (standard length for UUID v4)
- REQUEST_
ID_ HEADER - Default request ID header name
Traits§
- RequestID
Message - Extension trait for retrieving request IDs from HttpMessage
Functions§
- clear_
current_ request_ id - Clear the current request ID globally
- get_
current_ request_ id - Get the current request ID globally
- set_
current_ request_ id - Set the current request ID globally