pub struct Response {
pub status: i32,
pub body: String,
pub headers: String,
}Fields§
§status: i32§body: String§headers: StringImplementations§
Source§impl Response
impl Response
Sourcepub fn set_status(&mut self, status: i32)
pub fn set_status(&mut self, status: i32)
Set response-status
Example
res.set_status(404);Sourcepub fn get_status(&self) -> i32
pub fn get_status(&self) -> i32
Get response-status
Example
res.get_status();Sourcepub fn send_body(&mut self, body: &str)
pub fn send_body(&mut self, body: &str)
Send response-body as text
Example
res.send_body("body content");Sourcepub fn send_file(&mut self, path: &str)
pub fn send_file(&mut self, path: &str)
Send response-body as file
Example
res.send_file("path.html");Sourcepub fn set_header(&mut self, headers: &HashMap<&str, &str>)
pub fn set_header(&mut self, headers: &HashMap<&str, &str>)
Send response-headers in the form of a hashmap (this will overwrite an already set header for the response)
Example
let mut headers: HashMap<&str, &str> = HashMap::new();
headers.insert("key", "value");
res.set_header(&headers);Sourcepub fn append_header(&mut self, headers: &HashMap<&str, &str>)
pub fn append_header(&mut self, headers: &HashMap<&str, &str>)
Append response-headers in the form of a hashmap (this will append to the already set header for the response)
Example
let mut headers: HashMap<&str, &str> = HashMap::new();
headers.insert("key", "value");
res.append_header(&headers);Sourcepub fn clear_header(&mut self)
pub fn clear_header(&mut self)
Clear set response-header
Example
res.clear_header();Sourcepub fn set_string_header(&mut self, header: String)
pub fn set_string_header(&mut self, header: String)
Set response-header in the form of a string (this will overwrite an already set header for the response)
Example
res.set_string_header("Key: Value");Sourcepub fn append_string_header(&mut self, header: String)
pub fn append_string_header(&mut self, header: String)
Append response-header in the form of a string (this will append to the already set header for the response)
Example
res.append_string_header("Key: Value");Sourcepub fn get_header(&self) -> String
pub fn get_header(&self) -> String
Get response-header
Example
res.get_header();Auto Trait Implementations§
impl Freeze for Response
impl RefUnwindSafe for Response
impl Send for Response
impl Sync for Response
impl Unpin for Response
impl UnsafeUnpin for Response
impl UnwindSafe for Response
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more