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

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

Implementations

Set the body as a string

Set Generic Serialize as body and sets header Content-Type to application/json

Set the response status code

Set the response status code

Set the response Content-Type. A shortcode for

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

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

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

Sets a cookie on the response

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

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

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

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

route is used to return the route from the incoming request as a string.

set is used to set a header on the outgoing response.

remove is used to remove a header on the outgoing response.

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

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.