1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-08-30 16:40:21 +02:00

Add .peer_addr() #744

This commit is contained in:
Nikolay Kim
2019-04-16 10:11:38 -07:00
parent eb4f6b74fb
commit 420d3064c5
5 changed files with 48 additions and 16 deletions

View File

@@ -1,6 +1,6 @@
use std::cell::{Ref, RefCell, RefMut};
use std::fmt;
use std::rc::Rc;
use std::{fmt, net};
use actix_http::http::{HeaderMap, Method, Uri, Version};
use actix_http::{Error, Extensions, HttpMessage, Message, Payload, RequestHead};
@@ -170,6 +170,17 @@ impl HttpRequest {
self.url_for(name, &NO_PARAMS)
}
/// Peer socket address
///
/// Peer address is actual socket address, if proxy is used in front of
/// actix http server, then peer address would be address of this proxy.
///
/// To get client connection information `.connection_info()` should be used.
#[inline]
pub fn peer_addr(&self) -> Option<net::SocketAddr> {
self.head().peer_addr
}
/// Get *ConnectionInfo* for the current request.
#[inline]
pub fn connection_info(&self) -> Ref<ConnectionInfo> {