Skip to main content

http_extract/
lib.rs

1//! Strict, trust-aware extraction of HTTP request metadata.
2//!
3//! This crate operates primarily on [`http`] types and does not require a web
4//! framework, Tower, tracing, or OpenTelemetry. An opt-in `axum` feature adds
5//! only transport-peer extraction from Axum request extensions. Forwarding
6//! fields are never trusted implicitly.
7//!
8//! The crate root exposes small synchronous extractors for coherent field
9//! responsibilities. Applications compose only the functions they need at
10//! their framework boundary; this crate does not impose a request-context
11//! aggregate or an asynchronous adapter. Cargo features gate field-specific
12//! APIs; disabling default features leaves the shared Header helpers and
13//! [`Error`] available, and enabling a feature exposes only its documented API
14//! and dependencies.
15
16#![doc = include_str!("../README.md")]
17#![deny(unsafe_code)]
18#![warn(missing_docs, missing_debug_implementations)]
19
20#[cfg(feature = "api-key")]
21mod api_key;
22#[cfg(feature = "authority")]
23mod authority;
24#[cfg(feature = "authorization")]
25mod authorization;
26#[cfg(feature = "client-ip")]
27mod client_ip;
28#[cfg(feature = "client-ip-headers")]
29mod client_ip_headers;
30#[cfg(feature = "content-type")]
31mod content_type;
32#[cfg(feature = "forwarded")]
33mod forwarded;
34
35mod header;
36
37#[cfg(feature = "request-id")]
38mod request_id;
39#[cfg(feature = "x-forwarded")]
40mod x_forwarded;
41
42mod error;
43
44pub use error::*;
45pub use header::*;
46
47pub use http::{HeaderMap, HeaderName, HeaderValue, Request};
48
49// re-export the features
50#[cfg(feature = "api-key")]
51pub use api_key::*;
52#[cfg(feature = "authority")]
53pub use authority::*;
54#[cfg(feature = "authorization")]
55pub use authorization::*;
56#[cfg(feature = "client-ip")]
57pub use client_ip::*;
58#[cfg(feature = "client-ip-headers")]
59pub use client_ip_headers::*;
60#[cfg(feature = "content-type")]
61pub use content_type::*;
62#[cfg(feature = "forwarded")]
63pub use forwarded::*;
64#[cfg(feature = "request-id")]
65pub use request_id::*;
66#[cfg(feature = "x-forwarded")]
67pub use x_forwarded::*;