#axum #header #xrealip

headers-client-ip

A header for X-Real-IP compatible with headers crate

1 unstable release

0.1.0 Jun 27, 2022

#226 in #header

Download history 4/week @ 2024-09-19 1/week @ 2024-09-26

121 downloads per month

Custom license

5KB
80 lines

headers-client-ip

Use with axum

let app = Router::new().route("/ws", get(ws_handler));

async fn ws_handler(
    ws: WebSocketUpgrade,
    ip: Option<TypedHeader<XRealIP>>,
) -> impl IntoResponse {
    if let Some(TypedHeader(user_ip)) = ip {
        println!("`{}` connected", user_ip);
    }

    ws.on_upgrade(handle_socket)
}

async fn handle_socket(mut socket: WebSocket) {
    //
}

Dependencies

~1.5MB
~30K SLoC