modo/ip/mod.rs
1//! # modo::ip
2//!
3//! Client IP extraction with trusted proxy support.
4//!
5//! Provides:
6//! - [`ClientIp`] — axum extractor wrapping `std::net::IpAddr`
7//! - [`ClientIpLayer`] — Tower layer that resolves the client IP and inserts
8//! [`ClientIp`] into request extensions
9//! - [`extract_client_ip`] — low-level resolution function (headers + trusted
10//! proxies + fallback)
11//!
12//! For the richer [`ClientInfo`](crate::client::ClientInfo) extractor (with
13//! parsed device fields and a server-computed fingerprint), see
14//! [`crate::client`].
15//!
16//! ## Quick start
17//!
18//! ```rust,no_run
19//! use axum::{Router, routing::get};
20//! use modo::ip::{ClientIp, ClientIpLayer};
21//!
22//! let app: Router = Router::new()
23//! .route("/", get(handler))
24//! .layer(ClientIpLayer::new());
25//!
26//! async fn handler(ClientIp(ip): ClientIp) -> String {
27//! ip.to_string()
28//! }
29//! ```
30
31mod client_ip;
32mod extract;
33mod middleware;
34
35pub use client_ip::ClientIp;
36pub use extract::extract_client_ip;
37pub use middleware::ClientIpLayer;