Expand description
Header helpers used by axum-bound handlers: optimistic-locking ETag
parsing/emission, W3C traceparent extraction, RFC 7239 Forwarded/
X-Forwarded-For client-IP extraction (honored only from a configured
crate::trusted_proxy::TrustedProxyConfig — see enrich_context_from_headers,
#415), and context enrichment that bundles those.
Structs§
- Client
IpContext - The trusted-proxy configuration (if an
Extension<TrustedProxyConfig>was applied to the router), the verified socket peer (if the router is served viainto_make_service_with_connect_info), and a clone of the request’s fullhttp::Extensionsmap, bundled into a single axum extractor so every generated dispatch fn threads one new parameter instead of several (#415).
Functions§
- enrich_
context_ from_ headers - Enrich a
CratestackContextwith the request id (fromtraceparent) and the client IP recorded on audit events. Malformedtraceparentheaders are silently ignored here — the auth/header-validation layer is the right place to reject them, not the enrichment seam. - parse_
client_ ip - Extract the client IP
max_hopsentries in from the right end of whichever single headerheaderselects — never both. Falls back toNoneif that header is absent, empty, or the walk runs off the end of the chain. - parse_
if_ match_ version - Parse an
If-Matchheader carrying a strong ETag of the form"<int>". ReturnsNoneif the header is absent. Returns an error if the header is present but malformed (weak validators, non-integer payloads, etc.). - parse_
traceparent - Extract a W3C
traceparentheader, returning the trace-id portion when the header is present and well-formed. ReturnsOk(None)when absent — callers should mint their own request id in that case so every audit row carries something. The trace-id is the second hyphen-delimited segment per W3C Trace Context; this implementation does not validate the flags/version segments since banks usually rebuild traceparent at the edge anyway. - set_
version_ etag - Insert an
ETagheader onto a response, formatted as a strong validator over the integer optimistic-locking version.