pub struct RemoteAddr(pub IpAddr);Expand description
The remote address (peer IP) of the TCP connection.
This should be set by the HTTP server layer as a request extension to enable
secure IP-based rate limiting. Unlike X-Forwarded-For headers, this value
cannot be spoofed by clients.
§Example
ⓘ
// In your HTTP server code:
use fastapi_core::middleware::RemoteAddr;
use std::net::IpAddr;
// When accepting a connection:
let peer_addr: IpAddr = socket.peer_addr()?.ip();
request.insert_extension(RemoteAddr(peer_addr));Tuple Fields§
§0: IpAddrTrait Implementations§
Source§impl Clone for RemoteAddr
impl Clone for RemoteAddr
Source§fn clone(&self) -> RemoteAddr
fn clone(&self) -> RemoteAddr
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 RemoteAddr
impl Debug for RemoteAddr
Source§impl Display for RemoteAddr
impl Display for RemoteAddr
Source§impl Hash for RemoteAddr
impl Hash for RemoteAddr
Source§impl PartialEq for RemoteAddr
impl PartialEq for RemoteAddr
impl Copy for RemoteAddr
impl Eq for RemoteAddr
impl StructuralPartialEq for RemoteAddr
Auto Trait Implementations§
impl Freeze for RemoteAddr
impl RefUnwindSafe for RemoteAddr
impl Send for RemoteAddr
impl Sync for RemoteAddr
impl Unpin for RemoteAddr
impl UnwindSafe for RemoteAddr
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<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, _span: NoopSpan) -> Self
fn instrument(self, _span: NoopSpan) -> Self
Instruments this future with a span (no-op when disabled).
Source§fn in_current_span(self) -> Self
fn in_current_span(self) -> Self
Instruments this future with the current span (no-op when disabled).