pub struct Response { /* private fields */ }
Expand description
The struct that contains all the data to be sent to the browser.
Implementations
sourceimpl Response
impl Response
sourcepub fn new() -> Response
pub fn new() -> Response
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();
sourcepub fn set_status(self, status_code: i32) -> Self
pub fn set_status(self, status_code: i32) -> Self
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);
sourcepub fn set_content_type<'a>(self, content_type: &str) -> Self
pub fn set_content_type<'a>(self, content_type: &str) -> Self
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");
sourcepub fn set_location(self, url: &str) -> Self
pub fn set_location(self, url: &str) -> Self
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());
sourcepub fn add_session(
self,
session_name: &str,
session_key_in_redis: String
) -> Self
pub fn add_session(
self,
session_name: &str,
session_key_in_redis: String
) -> Self
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());
sourcepub fn set_content(self, content: &str) -> Self
pub fn set_content(self, content: &str) -> Self
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>");
sourcepub fn set_content_length(self, content_length: usize) -> Self
pub fn set_content_length(self, content_length: usize) -> Self
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);
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Response
impl Send for Response
impl Sync for Response
impl Unpin for Response
impl UnwindSafe for Response
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more