wae_https/middleware/
tracing.rs1use axum::{body::Body, extract::Request, http::Response, middleware::Next};
6use tracing::{Instrument, info, info_span};
7
8pub struct TracingLayer;
10
11impl TracingLayer {
12 pub async fn middleware(request: Request, next: Next) -> Response<Body> {
14 let method = request.method().to_string();
15 let uri = request.uri().to_string();
16 let span = info_span!("http_request", method = %method, uri = %uri);
17
18 async move {
19 info!("Request started");
20 let response = next.run(request).await;
21 info!("Request completed with status: {}", response.status());
22 response
23 }
24 .instrument(span)
25 .await
26 }
27}