pub struct Trusted<'a> {
pub host: Option<&'a str>,
pub scheme: Option<&'a str>,
pub by: Option<&'a str>,
pub ip: IpAddr,
}Expand description
Trusted data extracted from a request
Values returned by this struct are trusted and can be used to determine the real client information, given your configuration.
§Example
use trusted_proxies::{Config, Trusted};
let config = Config::new_local();
let mut request = http::Request::get("/").body(()).unwrap();
request.headers_mut().insert(http::header::FORWARDED, "for=1.2.3.4; proto=https; by=myproxy; host=mydomain.com:8080".parse().unwrap());
let socket_ip_addr = core::net::IpAddr::from([127, 0, 0, 1]);
let trusted = Trusted::from(socket_ip_addr, &request, &config);
assert_eq!(trusted.scheme(), Some("https"));
assert_eq!(trusted.host(), Some("mydomain.com"));
assert_eq!(trusted.port(), Some(8080));
assert_eq!(trusted.ip(), core::net::IpAddr::from([1, 2, 3, 4]));Fields§
§host: Option<&'a str>§scheme: Option<&'a str>§by: Option<&'a str>§ip: IpAddrImplementations§
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for Trusted<'a>
impl<'a> RefUnwindSafe for Trusted<'a>
impl<'a> Send for Trusted<'a>
impl<'a> Sync for Trusted<'a>
impl<'a> Unpin for Trusted<'a>
impl<'a> UnwindSafe for Trusted<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more