Struct BasicContext

Source
pub struct BasicContext {
    pub cookies: Vec<Cookie>,
    pub params: HashMap<String, String>,
    pub query_params: HashMap<String, String>,
    pub request: Request,
    pub status: u32,
    pub headers: HashMap<String, String>,
    /* private fields */
}

Fields§

§cookies: Vec<Cookie>§params: HashMap<String, String>§query_params: HashMap<String, String>§request: Request§status: u32§headers: HashMap<String, String>

Implementations§

Source§

impl BasicContext

Source

pub fn new() -> BasicContext

Source

pub fn body(&mut self, body_string: &str)

Set the body as a string

Source

pub fn get_body(&self) -> String

Source

pub fn set(&mut self, key: &str, value: &str)

Set a header on the response

Source

pub fn remove(&mut self, key: &str)

Remove a header on the response

Source

pub fn status(&mut self, code: u32)

Set the response status code

Source

pub fn content_type(&mut self, c_type: &str)

Set the response Content-Type. A shortcode for

ctx.set("Content-Type", "some-val");
Source

pub fn redirect(&mut self, destination: &str)

Set up a redirect, will default to 302, but can be changed after the fact.

ctx.set("Location", "/some-path");
ctx.status(302);
Source

pub fn cookie(&mut self, name: &str, value: &str, options: &CookieOptions)

Sets a cookie on the response

Trait Implementations§

Source§

impl Context for BasicContext

Source§

type Response = Response

Source§

fn get_response(self) -> Self::Response

Source§

fn set_body(&mut self, body: Vec<u8>)

Source§

impl Default for BasicContext

Source§

fn default() -> BasicContext

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

impl HasCookies for BasicContext

Source§

fn set_cookies(&mut self, cookies: Vec<Cookie>)

Source§

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

Source§

impl HasQueryParams for BasicContext

Source§

fn set_query_params(&mut self, query_params: HashMap<String, String>)

Source§

fn route(&self) -> &str

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.