[][src]Trait rusty_express::prelude::ResponseWriter

pub trait ResponseWriter {
    fn status(&mut self, status: u16);
fn header(&mut self, field: &str, value: &str, allow_replace: bool);
fn set_header(&mut self, field: &str, value: &str);
fn send(&mut self, content: &str);
fn send_file(&mut self, file_path: &str) -> u16;
fn send_file_from_path(&mut self, path: PathBuf) -> u16;
fn send_file_async(&mut self, file_loc: &str);
fn send_file_from_path_async(&mut self, path: PathBuf);
fn send_template<T: EngineContext + Send + Sync + 'static>(
        &mut self,
        file_path: &str,
        context: Box<T>
    ) -> u16;
fn set_cookie(&mut self, cookie: Cookie);
fn set_cookies(&mut self, cookie: &[Cookie]);
fn clear_cookies(&mut self);
fn can_keep_alive(&mut self, can_keep_alive: bool);
fn keep_alive(&mut self, to_keep: bool);
fn set_content_type(&mut self, content_type: &str);
fn redirect(&mut self, path: &str); }

Required methods

fn status(&mut self, status: u16)

fn header(&mut self, field: &str, value: &str, allow_replace: bool)

fn set_header(&mut self, field: &str, value: &str)

fn send(&mut self, content: &str)

fn send_file(&mut self, file_path: &str) -> u16

fn send_file_from_path(&mut self, path: PathBuf) -> u16

fn send_file_async(&mut self, file_loc: &str)

fn send_file_from_path_async(&mut self, path: PathBuf)

fn send_template<T: EngineContext + Send + Sync + 'static>(
    &mut self,
    file_path: &str,
    context: Box<T>
) -> u16

fn set_cookies(&mut self, cookie: &[Cookie])

fn clear_cookies(&mut self)

fn can_keep_alive(&mut self, can_keep_alive: bool)

fn keep_alive(&mut self, to_keep: bool)

fn set_content_type(&mut self, content_type: &str)

fn redirect(&mut self, path: &str)

Loading content...

Implementors

impl ResponseWriter for Response[src]

fn set_header(&mut self, field: &str, value: &str)[src]

set_header is a sugar to the header API, and it's created to simplify the majority of the use cases for setting the response header.

By default, the field-value pair will be set to the response header, and override any existing pairs if they've been set prior to the API call.

Examples

resp.set_header("Content-Type", "application/javascript"); assert!(resp.get_header("Content-Type").unwrap(), &String::from("application/javascript"));

fn send_file(&mut self, file_loc: &str) -> u16[src]

Send a static file as part of the response to the client. Return the http header status that can be set directly to the response object using:

resp.status(<returned_status_value_from_this_api>);

For example, if the file is read and parsed successfully, we will return 200; if we can't find the file, we will return 404; if there are errors when reading the file from its location, we will return 500.

side effect: if the file is read and parsed successfully, we will set the content type based on file extension. You can always reset the value for this auto-generated content type response attribute. ...

fn redirect(&mut self, path: &str)[src]

Can only redirect to internal path, no outsource path, sorry for the hackers (FYI, you can still hack the redirection link via Javascript)!

Loading content...