LCOV - code coverage report
Current view: top level - compute_tools/src/http/middleware - request_id.rs (source / functions) Coverage Total Hit
Test: 6df3fc19ec669bcfbbf9aba41d1338898d24eaa0.info Lines: 0.0 % 7 0
Test Date: 2025-03-12 18:28:53 Functions: 0.0 % 2 0

            Line data    Source code
       1              : use axum::{extract::Request, middleware::Next, response::Response};
       2              : use uuid::Uuid;
       3              : 
       4              : use crate::http::headers::X_REQUEST_ID;
       5              : 
       6              : /// This middleware function allows compute_ctl to generate its own request ID
       7              : /// if one isn't supplied. The control plane will always send one as a UUID. The
       8              : /// neon Postgres extension on the other hand does not send one.
       9            0 : pub async fn maybe_add_request_id_header(mut request: Request, next: Next) -> Response {
      10            0 :     let headers = request.headers_mut();
      11            0 :     if !headers.contains_key(X_REQUEST_ID) {
      12            0 :         headers.append(X_REQUEST_ID, Uuid::new_v4().to_string().parse().unwrap());
      13            0 :     }
      14              : 
      15            0 :     next.run(request).await
      16            0 : }
        

Generated by: LCOV version 2.1-beta