Skip to main content

http_middleware

Function http_middleware 

Source
pub async fn http_middleware(
    __arg0: State<Arc<Metrics>>,
    req: Request,
    next: Next,
) -> Response
Expand description

Axum middleware: record HTTP method + MatchedPath + status + duration.

Runs after the handler finishes so we see the final status. Missing MatchedPath (404 for unrouted paths) is labelled "unknown" to cap cardinality — a flood of distinct 404 paths would otherwise explode the path label space.