Struct edge::Response
[−]
[src]
pub struct Response<'a> { /* fields omitted */ }
Methods
impl<'a> Response<'a>
[src]
fn status(&mut self, status: Status) -> &mut Self
Sets the status code of this response.
fn content_type<S: Into<Vec<u8>>>(&mut self, mime: S) -> &mut Self
Sets the Content-Type header.
fn len(&mut self, len: u64) -> &mut Self
Sets the Content-Length header.
fn location<S: Into<String>>(&mut self, url: S) -> &mut Self
Sets the Location header.
fn redirect(self, url: &'a str, status: Option<Status>) -> Result<()>
Redirects to the given URL with the given status, or 302 Found if none is given.
fn header<H: Header + HeaderFormat>(&mut self, header: H) -> &mut Self
Sets the given header.
fn header_raw<K: Into<Cow<'static, str>> + Debug, V: Into<Vec<u8>>>(
&mut self,
name: K,
value: V
) -> &mut Self
&mut self,
name: K,
value: V
) -> &mut Self
Sets the given header with raw strings.
fn end(self, status: Status) -> Result<()>
Ends this response with the given status and an empty body
fn render<P: AsRef<Path>, T: ToJson>(self, path: P, data: T) -> Result<()>
fn send<D: AsRef<[u8]>>(self, content: D) -> Result<()>
Sends the given content and ends this response. Status defaults to 200 Ok, headers must have been set before this method is called.
fn send_file<P: AsRef<Path>>(self, path: P) -> Result<()>
Sends the given file, setting the Content-Type based on the file's extension. Known extensions are htm, html, jpg, jpeg, png, js, css. If the file does not exist, this method sends a 404 Not Found response.
fn stream<F, R>(self, source: F) -> Result<()> where
F: FnOnce(&mut Write) -> Result<R>,
F: FnOnce(&mut Write) -> Result<R>,
Writes the body of this response using the given source function.
Sets a cookie with the given name and value. If set, the set_options function will be called to update the cookie's options.