MCPcopy Index your code
hub / github.com/aws/aws-lambda-rust-runtime / mw_sample

Function mw_sample

examples/http-axum-middleware/src/main.rs:17–23  ·  view source on GitHub ↗

Sample middleware that logs the request id

(req: axum::extract::Request, next: axum::middleware::Next)

Source from the content-addressed store, hash-verified

15
16// Sample middleware that logs the request id
17async 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
25async fn handler_sample(body: Json<Value>) -> Json<Value> {
26 Json(json!({ "echo": *body }))

Callers

nothing calls this directly

Calls 1

runMethod · 0.45

Tested by

no test coverage detected