Connection info
ConnectionInfo
groups together information about the HTTP connection
used to transmit the request you're currently processing.
ConnectionInfo
gives you access to the peer address of the client that sent the request, via
the ConnectionInfo::peer_addr
method.
Many applications include the peer address in their request logs, for example.
Security implications
The peer address should not be treated as the clients IP address. Check out "The perils of the 'real' client IP" by Adam Pritchard to learn more about the issues you might run into.
Injection
Inject ConnectionInfo
to access the peer address via its peer_addr
method: