headers-client-ip

Crates.ioheaders-client-ip
lib.rsheaders-client-ip
version0.1.0
sourcesrc
created_at2022-06-27 17:26:07.103683
updated_at2022-06-27 17:26:07.103683
descriptionA header for X-Real-IP compatible with headers crate
homepage
repositoryhttps://github.com/dimitrmo/headers-client-ip
max_upload_size
id614239
size5,640
Dimitrios Mouratidis (dimitrmo)

documentation

README

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) {
    //
}
Commit count: 16

cargo fmt