Skip to content

Provide access to remote IP address in incoming server requests #1650

Closed
@klausi

Description

@klausi

When writing a server in Hyper I should be able to retrieve the remote IP address from the request.

@seanmonstar mentioned in #1410 that an API similar to the client (#1402) might be relevant?

API usage could then look like this:

fn respond_with_sender_ip(request: Request<Body>) -> BoxFut {
    let remote_address = request
        .extensions()
        .get::<HttpInfo>()
        .expect("something something sets HttpInfo")
        .remote_addr();

    Box::new(future::ok(Response::new(Body::from(remote_address))))
}

(Please edit this to make the proposed API usage correct :-)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-serverArea: server.B-upstreamBlocked: needs a change in a dependency or the compiler.C-featureCategory: feature. This is adding a new feature.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions