Skip to main content

Request

Struct Request 

Source
pub struct Request { /* private fields */ }
Expand description

A fully-received HTTP request: the request line, headers, and a fully buffered body.

The engine buffers the entire body before yielding a Request, so handlers see a complete message. Streaming request bodies are out of scope for this version.

Implementations§

Source§

impl Request

Source

pub fn method(&self) -> &Method

The request method.

Source

pub fn target(&self) -> &str

The raw request target (origin-form path, possibly with a query string), exactly as sent on the request line.

Source

pub fn path(&self) -> &str

The path portion of the target, i.e. everything before the first ?.

Source

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

The query string (without the leading ?), if present.

Source

pub fn version(&self) -> Version

The HTTP version.

Source

pub fn headers(&self) -> &Headers

The request headers.

Source

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

The value of the Host header, if any.

Source

pub fn body(&self) -> &[u8]

The buffered request body.

Source

pub fn body_str(&self) -> Cow<'_, str>

The request body interpreted as UTF-8 (lossily).

Source

pub fn into_body(self) -> Vec<u8>

Consume the request and return the owned body bytes.

Source

pub fn param(&self, name: &str) -> Option<&str>

The value of a path parameter captured by the Router, e.g. req.param("id") for a route registered as /users/:id. Returns None if the request was not routed or has no such parameter.

Source

pub fn params(&self) -> impl Iterator<Item = (&str, &str)>

All captured path parameters, in match order.

Trait Implementations§

Source§

impl Clone for Request

Source§

fn clone(&self) -> Request

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 Debug for Request

Source§

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

Formats the value using the given formatter. Read more
Source§

impl From<Request<Vec<u8>>> for Request

Source§

fn from(req: Request<Vec<u8>>) -> Self

Converts to this type from the input type.
Source§

impl TryFrom<&Request> for Request<Vec<u8>>

Source§

type Error = HttpConvertError

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

fn try_from(req: &Request) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

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 = 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.