pub struct Response { /* private fields */ }
Expand description

The struct that contains all the data to be sent to the browser.

Implementations

Creates and returns an instance of the ´Response´ struct with all the fields empty.

Examples
use kalgan::http::response::Response;

let response: Response = Response::new();

Sets the status field of the response and returns the instance.

Examples
use kalgan::http::response::Response;

let response: Response = Response::new().set_status(200);

Sets the content type field of the response and returns the instance.

Examples
use kalgan::http::response::Response;

let response: Response = Response::new().set_content_type("text/html; charset=UTF-8");

Sets the location field of the response and returns the instance.

Examples
use kalgan::http::response::Response;

let response: Response = Response::new().set_location("/home");

Adds a cookie to the response and returns the instance.

Examples
use kalgan::http::response::Response;
use kalgan::storage::cookie::Cookie;

let mut response: Response = Response::new();
let mut cookie: Cookie = Cookie::new();
response.add_cookie(cookie.clone());

Adds a cookie session to the response and returns the instance.

Examples
use kalgan::http::response::Response;

let mut response: Response = Response::new().add_session("session_name", "session_key".to_string());

Sets the content of the response and returns the instance.

Examples
use kalgan::http::response::Response;

let response: Response = Response::new().set_content("<h1>Hello World</h1>");

Sets the content length of the response and returns the instance.

Examples
use kalgan::http::response::Response;

let response: Response = Response::new().set_content_length(50);

Creates a string with all the response data to be sent to the browser.

Examples
use kalgan::http::response::Response;

let response: Vec<u8> = Response::new().create();

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. 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

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

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)

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.