Struct rusty_express::prelude::Response
source · pub struct Response { /* private fields */ }
Implementations§
Trait Implementations§
source§impl ResponseStates for Response
impl ResponseStates for Response
source§fn get_channels(
&mut self
) -> Result<(Arc<Sender<Box<String>>>, Arc<Receiver<Box<String>>>), &'static str>
fn get_channels(
&mut self
) -> Result<(Arc<Sender<Box<String>>>, Arc<Receiver<Box<String>>>), &'static str>
get_channels will create the channels for communicating between the chunk generator threads and the main stream. Listen to the receiver for any client communications, and use the sender to send any ensuing responses.
fn to_keep_alive(&self) -> bool
fn get_redirect_path(&self) -> String
fn get_header(&self, key: &str) -> Option<&String>
fn get_content_type(&self) -> String
fn status_is_set(&self) -> bool
fn has_contents(&self) -> bool
fn is_header_only(&self) -> bool
source§impl ResponseWriter for Response
impl ResponseWriter for Response
source§fn set_header(&mut self, field: &str, value: &str)
fn set_header(&mut self, field: &str, value: &str)
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”));
source§fn send_file(&mut self, file_loc: &str) -> u16
fn send_file(&mut self, file_loc: &str) -> u16
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. …
source§fn redirect(&mut self, path: &str)
fn redirect(&mut self, path: &str)
Can only redirect to internal path, no outsource path, sorry for the hackers (FYI, you can still hack the redirection link via Javascript)!