pub struct ClientIp(pub IpAddr);
Expand description
Client IP extractor with configurable source
The configuration would include knowing the header the last proxy (the
one you own or the one your cloud server provides) is using to store
user connection IP. Then you’d need to pass a corresponding
ClientIpSource
variant into the axum::routing::Router::layer
as
an extension. Look at the example.
Tuple Fields§
§0: IpAddr
Trait Implementations§
Source§impl<S> FromRequestParts<S> for ClientIpwhere
S: Sync,
impl<S> FromRequestParts<S> for ClientIpwhere
S: Sync,
impl Copy for ClientIp
Auto Trait Implementations§
impl Freeze for ClientIp
impl RefUnwindSafe for ClientIp
impl Send for ClientIp
impl Sync for ClientIp
impl Unpin for ClientIp
impl UnwindSafe for ClientIp
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<S, T> FromRequest<S, ViaParts> for T
impl<S, T> FromRequest<S, ViaParts> for T
Source§type Rejection = <T as FromRequestParts<S>>::Rejection
type Rejection = <T as FromRequestParts<S>>::Rejection
If the extractor fails it’ll use this “rejection” type. A rejection is
a kind of error that can be converted into a response.
Source§fn from_request(
req: Request<Body>,
state: &S,
) -> impl Future<Output = Result<T, <T as FromRequest<S, ViaParts>>::Rejection>>
fn from_request( req: Request<Body>, state: &S, ) -> impl Future<Output = Result<T, <T as FromRequest<S, ViaParts>>::Rejection>>
Perform the extraction.