Struct Request

Source
pub struct Request {
    pub headers: SmallVec<[((usize, usize), (usize, usize)); 8]>,
    pub params: HashMap<String, String>,
    /* private fields */
}
Expand description

The request object is the default request object provied by Thruster. If a different server is used, such as Hyper, then you’ll need to reference that server’s “request” documentation instead.

Fields§

§headers: SmallVec<[((usize, usize), (usize, usize)); 8]>§params: HashMap<String, String>

Implementations§

Source§

impl Request

Source

pub fn new() -> Self

Create a new, blank, request.

Source

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

Get the raw pointer to the byte array of the request

Source

pub fn body(&self) -> &str

Get the body as a utf8 encoded string

Source

pub fn method(&self) -> &str

Get the method as a string

Source

pub fn path(&self) -> &str

Get the path as a string (“/some/path”)

Source

pub fn version(&self) -> u8

Get the HTTP version

Source

pub fn headers(&self) -> HashMap<String, String>

Get an HashMap of the provided headers. The HashMap is lazily computed, so avoid this method unless you need to access headers.

Source

pub fn body_as<'a, T>(&self, body: &'a str) -> Result<T>
where T: Deserialize<'a>,

Automatically apply a serde deserialization to the body

Source

pub fn params(&self) -> &HashMap<String, String>

Fetch the params from the route, e.g. The route “/some/:key” when applied to an incoming request for “/some/value” will populate params with { key: "value" }

Trait Implementations§

Source§

impl Debug for Request

Source§

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

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

impl Default for Request

Source§

fn default() -> Request

Returns the “default value” for a type. Read more
Source§

impl RequestWithParams for Request

Source§

fn set_params(&mut self, params: HashMap<String, String>)

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