Struct edge::Response [] [src]

pub struct Response {
    // some fields omitted
}

This represents the response that will be sent back to the application.

Includes a status code (default 200 OK), headers, and a body. The response can be updated and sent back immediately in a synchronous way, or deferred pending some computation (asynchronous mode).

The response is sent when it is dropped.

Methods

impl Response

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: &str, status: Option<Status>)

Redirects to the given URL with the given status, or 302 Found if none is given.

fn header<H: Header>(&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

Sets the given header with raw strings.

fn end(self, status: Status)

Ends this response with the given status and an empty body

fn render<P: AsRef<Path>, T: ToJson>(self, path: P, data: T)

Renders the template at the given path using the given data.

fn send<D: Into<Vec<u8>>>(self, content: D)

Sends the given content and ends this response. Status defaults to 200 Ok, headers must have been set before this method is called.

fn append<D: AsRef<[u8]>>(&mut self, content: D)

Appends the given content to this response's body. Will change to support asynchronous use case.

fn send_file<P: AsRef<Path>>(self, path: P)

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 cookie(&mut self, cookie: Cookie)

Sets the given cookie.

Trait Implementations

impl Drop for Response

fn drop(&mut self)