Skip to main content

HttpRequestContext

Struct HttpRequestContext 

Source
pub struct HttpRequestContext<'request> { /* private fields */ }
Expand description

Mutable, request-local context shared by runtime-neutral HTTP middleware.

The base request remains borrowed. Proxy middleware can replace the effective client IP, scheme, and host without rewriting the adapter’s receive buffer. Typed extensions are allocated only when inserted.

Implementations§

Source§

impl<'request> HttpRequestContext<'request>

Source

pub fn request(&self) -> &dyn HttpRequestView

Source

pub fn client_ip(&self) -> Option<IpAddr>

Source

pub fn set_client_ip(&mut self, client_ip: IpAddr)

Source

pub fn scheme(&self) -> &str

Source

pub fn set_scheme(&mut self, scheme: impl Into<String>)

Source

pub fn host(&self) -> Option<&str>

Source

pub fn set_host(&mut self, host: impl Into<String>)

Source

pub fn insert_extension<T: 'static>(&mut self, value: T)

Source

pub fn extension<T: 'static>(&self) -> Option<&T>

Source

pub fn connection_info(&self) -> ConnectionInfo

Snapshots the normalized client IP, scheme, and host so the dispatch path can carry them into the operation request context.

Auto Trait Implementations§

§

impl<'request> !RefUnwindSafe for HttpRequestContext<'request>

§

impl<'request> !Send for HttpRequestContext<'request>

§

impl<'request> !Sync for HttpRequestContext<'request>

§

impl<'request> !UnwindSafe for HttpRequestContext<'request>

§

impl<'request> Freeze for HttpRequestContext<'request>

§

impl<'request> Unpin for HttpRequestContext<'request>

§

impl<'request> UnsafeUnpin for HttpRequestContext<'request>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> BackgroundExt for T

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ResponseExt for T

Source§

fn header( self, name: impl Into<String>, value: impl Into<String>, ) -> WithHeaders<Self>

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.