1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//! The matched-route enrichment adapter โ a `from_fn` middleware that bridges
//! axum's `MatchedPath` to the observe crate's `MatchedRoute`.
//!
//! This is the smallest backward-compatible improvement to the observe
//! integration (engine spec ยง8): the observe crate records matched route
//! *templates* (e.g. `/users/{id}`), not concrete paths (e.g. `/users/928137`).
//! The observe crate's `HttpLayer` reads `MatchedRoute` from request
//! extensions, but axum populates `MatchedPath` (a different type). This
//! adapter copies the template from `MatchedPath` โ `MatchedRoute` so
//! `HttpLayer` sees it.
//!
//! Applied via `Router::route_layer` (runs only on matched routes, after
//! `MatchedPath` is set by axum's route matcher). Positioned as the
//! outermost route_layer so it runs before `HttpLayer` reads the extension.
//!
//! Gated by the `observe` feature: needs `axum::extract::MatchedPath` (enabled
//! by `axum/matched-path` in the observe feature) and
//! `arcature_observe::MatchedRoute`.
use crateMatchedPath;
use crateNext;
use crateResponse;
/// Read `MatchedPath` from request extensions and insert a `MatchedRoute` with
/// the same template, so `HttpLayer` records the route template (not the
/// concrete path) in its `HttpRecord`.
///
/// When `MatchedPath` is absent (e.g. on a fallback route โ which should not
/// happen inside a `route_layer`, but defense-in-depth), the request passes
/// through unchanged.
pub async