[][src]Struct thruster::context::basic_context::BasicContext

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>,
    // some fields omitted
}

Fields

cookies: Vec<Cookie>params: HashMap<String, String>query_params: HashMap<String, String>request: Requeststatus: u32headers: HashMap<String, String>

Methods

impl BasicContext[src]

pub fn new() -> BasicContext[src]

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

Set the body as a string

pub fn get_body(&self) -> String[src]

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

Set the response status code

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

Set the response Content-Type. A shortcode for

This example is not tested
ctx.set("Content-Type", "some-val");

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

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

This example is not tested
ctx.set("Location", "/some-path");
ctx.status(302);

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

Sets a cookie on the response

Trait Implementations

impl Context for BasicContext[src]

type Response = Response

impl Default for BasicContext[src]

impl HasCookies for BasicContext[src]

impl HasQueryParams for BasicContext[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.