pub struct ClientIpConfig { /* private fields */ }Available on crate feature
server only.Expand description
Config for extract client ip
Implementations§
Source§impl ClientIpConfig
impl ClientIpConfig
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new ClientIpConfig with default values
default remote ip headers: ["X-Real-IP", "X-Forwarded-For"]
default trusted cidrs: ["0.0.0.0/0", "::/0"]
Sourcepub fn with_remote_ip_headers<I>(
self,
headers: I,
) -> Result<Self, InvalidHeaderName>
pub fn with_remote_ip_headers<I>( self, headers: I, ) -> Result<Self, InvalidHeaderName>
Sourcepub fn with_trusted_cidrs<H>(self, cidrs: H) -> Selfwhere
H: IntoIterator<Item = IpNet>,
pub fn with_trusted_cidrs<H>(self, cidrs: H) -> Selfwhere
H: IntoIterator<Item = IpNet>,
Get Real Client IP if it is trusted, otherwise it will just return caller ip.
See ClientIp for more details.
§Example
use volo_http::server::utils::client_ip::ClientIpConfig;
let client_ip_config = ClientIpConfig::new()
.with_trusted_cidrs(vec!["0.0.0.0/0".parse().unwrap(), "::/0".parse().unwrap()]);Trait Implementations§
Source§impl Clone for ClientIpConfig
impl Clone for ClientIpConfig
Source§fn clone(&self) -> ClientIpConfig
fn clone(&self) -> ClientIpConfig
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ClientIpConfig
impl Debug for ClientIpConfig
Auto Trait Implementations§
impl Freeze for ClientIpConfig
impl RefUnwindSafe for ClientIpConfig
impl Send for ClientIpConfig
impl Sync for ClientIpConfig
impl Unpin for ClientIpConfig
impl UnwindSafe for ClientIpConfig
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