Sample middleware that logs the request id
(req: axum::extract::Request, next: axum::middleware::Next)
| 15 | |
| 16 | // Sample middleware that logs the request id |
| 17 | async fn mw_sample(req: axum::extract::Request, next: axum::middleware::Next) -> impl axum::response::IntoResponse { |
| 18 | let context = req.extensions().get::<lambda_http::request::RequestContext>(); |
| 19 | if let Some(ApiGatewayV1(ctx)) = context { |
| 20 | tracing::info!("RequestId = {:?}", ctx.request_id); |
| 21 | } |
| 22 | next.run(req).await |
| 23 | } |
| 24 | |
| 25 | async fn handler_sample(body: Json<Value>) -> Json<Value> { |
| 26 | Json(json!({ "echo": *body })) |