Struct thruster::context::basic_context::BasicContext [−][src]
pub struct BasicContext { pub cookies: Vec<Cookie>, pub params: Option<HashMap<String, String>>, pub query_params: Option<HashMap<String, String>>, pub request: Request, pub status: u32, pub headers: HashMap<String, String>, // some fields omitted }
Fields
params: Option<HashMap<String, String>>
query_params: Option<HashMap<String, String>>
request: Request
status: u32
headers: HashMap<String, String>
Implementations
impl BasicContext
[src]
impl BasicContext
[src]pub fn new() -> BasicContext
[src]
pub fn get_body(&self) -> String
[src]
pub fn content_type(&mut self, c_type: &str)
[src]
pub fn content_type(&mut self, c_type: &str)
[src]Set the response Content-Type
. A shortcode for
ctx.set("Content-Type", "some-val");
pub fn redirect(&mut self, destination: &str)
[src]
pub fn redirect(&mut self, destination: &str)
[src]Set up a redirect, will default to 302, but can be changed after the fact.
ctx.set("Location", "/some-path"); ctx.status(302);
pub fn cookie(&mut self, name: &str, value: &str, options: &CookieOptions)
[src]
pub fn cookie(&mut self, name: &str, value: &str, options: &CookieOptions)
[src]Sets a cookie on the response
Trait Implementations
impl Clone for BasicContext
[src]
impl Clone for BasicContext
[src]impl Context for BasicContext
[src]
impl Context for BasicContext
[src]type Response = Response
fn get_response(self) -> Self::Response
[src]
fn get_response(self) -> Self::Response
[src]get_response returns a fully created response object based on the contents of the Context. This means setting the body according to whatever has been stored via set_body and/or set_body_bytes, as well as adding the proper headers that have been added via the set method. Read more
fn set_body(&mut self, body: Vec<u8>)
[src]
fn set_body(&mut self, body: Vec<u8>)
[src]set_body is used to set the body using a vec of bytes on the context. The contents will be used later for generating the correct response. Read more
fn set_body_bytes(&mut self, body_bytes: Bytes)
[src]
fn set_body_bytes(&mut self, body_bytes: Bytes)
[src]set_body_byte is used to set the body using a Bytes object on the context. The contents will be used later for generating the correct response. Read more
impl Default for BasicContext
[src]
impl Default for BasicContext
[src]fn default() -> BasicContext
[src]
fn default() -> BasicContext
[src]Returns the “default value” for a type. Read more
impl HasCookies for BasicContext
[src]
impl HasCookies for BasicContext
[src]fn set_cookies(&mut self, cookies: Vec<Cookie>)
[src]
fn get_cookies(&self) -> Vec<String>
[src]
fn get_header(&self, key: &str) -> Vec<String>
[src]
impl HasQueryParams for BasicContext
[src]
impl HasQueryParams for BasicContext
[src]fn set_query_params(&mut self, query_params: HashMap<String, String>)
[src]
Auto Trait Implementations
impl RefUnwindSafe for BasicContext
impl Send for BasicContext
impl Sync for BasicContext
impl Unpin for BasicContext
impl UnwindSafe for BasicContext
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn to_owned(&self) -> T
[src]Creates owned data from borrowed data, usually by cloning. Read more
pub fn clone_into(&self, target: &mut T)
[src]
pub fn clone_into(&self, target: &mut T)
[src]🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more