headers-client-ip 0.1.0

A header for X-Real-IP compatible with headers crate
Documentation
  • Coverage
  • 0%
    0 out of 2 items documented0 out of 1 items with examples
  • Size
  • Source code size: 9.65 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.62 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 17s Average build duration of successful builds.
  • all releases: 17s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • dimitrmo/headers-client-ip
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • dimitrmo

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) {
    //
}