Skip to main content

Module headers

Module headers 

Source
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§

ClientIpContext
The trusted-proxy configuration (if an Extension<TrustedProxyConfig> was applied to the router), the verified socket peer (if the router is served via into_make_service_with_connect_info), and a clone of the request’s full http::Extensions map, 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 CratestackContext with the request id (from traceparent) and the client IP recorded on audit events. Malformed traceparent headers 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_hops entries in from the right end of whichever single header header selects — never both. Falls back to None if that header is absent, empty, or the walk runs off the end of the chain.
parse_if_match_version
Parse an If-Match header carrying a strong ETag of the form "<int>". Returns None if 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 traceparent header, returning the trace-id portion when the header is present and well-formed. Returns Ok(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 ETag header onto a response, formatted as a strong validator over the integer optimistic-locking version.