Skip to main content

Request

Struct Request 

Source
pub struct Request<'r> { /* private fields */ }
Expand description

The request as gates and handlers read it: the parts web-net has checked (the host matched a site, the path is canonical) and the raw request underneath.

Implementations§

Source§

impl<'r> Request<'r>

Source

pub fn method(&self) -> Method

The method.

Source

pub fn path(&self) -> &'r str

The canonical path inside the site: the base path removed, percent escapes in their one canonical form. / for the site root.

Source

pub fn query(&self) -> Option<&'r str>

The query after ?, as received (validated by the parser, not decoded).

Source

pub fn host(&self) -> &'r str

The host the request named, as received (empty for an HTTP/1.0 request without one). It matched one of the site’s hosts, unless the site accepts any host.

Source

pub fn header(&self, name: &str) -> Option<&'r [u8]>

The first value of a field.

Source

pub fn header_str(&self, name: &str) -> Option<&'r str>

The first value of a field, if it is UTF-8.

Source

pub fn cookie(&self, name: &str) -> Result<Option<&'r str>, Ambiguous>

The value of the cookie name, read with cookie-net. Ok(None) when there is no such cookie.

§Errors

Ambiguous when the name appears twice, or the request has more than one Cookie field: a sign of cookie tossing, never resolved by picking one.

Source

pub fn client(&self) -> &'r ClientInfo

The client, as serve-net established it (the real address behind a trusted proxy).

Source

pub fn scheme(&self) -> Scheme

https when the request came over TLS (or from a trusted proxy that said so).

Source

pub fn route(&self) -> Option<&'r str>

The pattern of the matched route (/users/:id), once routing ran.

Source

pub fn id(&self) -> RequestId

The request’s reference.

Source

pub fn envelope(&self) -> &'r Envelope

serve-net’s facts about the request.

Source

pub fn raw(&self) -> &'r HttpRequest<'r>

The raw request: the target as received, every field, the body.

Trait Implementations§

Source§

impl<'r> Clone for Request<'r>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'r> Copy for Request<'r>

Source§

impl Debug for Request<'_>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'r> Forget for Request<'r>

§

impl<'r> Freeze for Request<'r>

§

impl<'r> RefUnwindSafe for Request<'r>

§

impl<'r> Send for Request<'r>

§

impl<'r> Sync for Request<'r>

§

impl<'r> Unpin for Request<'r>

§

impl<'r> UnsafeUnpin for Request<'r>

§

impl<'r> UnwindSafe for Request<'r>

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> 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.