Skip to main content

Module ip

Module ip 

Source
Expand description

§modo::ip

Client IP extraction with trusted proxy support.

Always available (no feature flag required).

Provides:

  • ClientIp — axum extractor wrapping std::net::IpAddr
  • ClientIpLayer — Tower layer that resolves the client IP and inserts ClientIp into request extensions
  • extract_client_ip — low-level resolution function (headers + trusted proxies + fallback)

§Quick start

use axum::{Router, routing::get};
use modo::{ClientIp, ClientIpLayer};

let app: Router = Router::new()
    .route("/", get(handler))
    .layer(ClientIpLayer::new());

async fn handler(ClientIp(ip): ClientIp) -> String {
    ip.to_string()
}

Structs§

ClientIp
Resolved client IP address.
ClientIpLayer
Tower layer that extracts the client IP address and inserts ClientIp into request extensions.

Functions§

extract_client_ip
Resolve the real client IP from headers and connection info.