Crate actix_web_request_uuid

Source
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
RequestIDMiddleware
Middleware for generating and managing request IDs
RequestIDService
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§

RequestIDMessage
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