Struct wasm_framework::Response[][src]

pub struct Response { /* fields omitted */ }

Worker response for HTTP requests. The Response is created/accessed from ctx.response() and has a builder-like api.

Implementations

impl Response[src]

pub fn status(&mut self, status: u16) -> &mut Self[src]

Sets response status

pub fn body<T: Into<Body>>(&mut self, body: T) -> &mut Self[src]

Sets response body to the binary data

pub fn json<T: Serialize>(&mut self, value: &T) -> Result<&mut Self, Error>[src]

Sets response body to value serialized as json, and sets content-type to application/json

pub fn text<T: Into<String>>(&mut self, text: T) -> &mut Self[src]

Sets response body to the text string, encoded as utf-8

pub fn header<K: AsRef<str>, V: AsRef<str>>(
    &mut self,
    key: K,
    val: V
) -> Result<&mut Self, Error>
[src]

Sets a header for this response

pub fn content_type<T: AsRef<str>>(
    &mut self,
    ctype: T
) -> Result<&mut Self, Error>
[src]

Sets response content type

pub fn get_status(&self) -> u16[src]

Returns the status of this response

pub fn get_body(&self) -> &[u8][src]

Returns body of this response.

pub fn get_headers(&self) -> Option<&Headers>[src]

Returns headers for this response, or None if no headers have been set

pub fn is_empty(&self) -> bool[src]

Returns true if the body is empty

pub fn is_unset(&self) -> bool[src]

True if the response has not been filled in (none of status(), text() or body() has been called). (even if status() is called with 200 status or body is set to empty) This could be used as a flag for chained handlers to determine whether a previous handler has filled in the response yet. Setting headers (including content_type or user_agent) does not mark the request “set” This is so that headers can be set at the top of a handler, before errors may occur

Trait Implementations

impl Debug for Response[src]

impl Default for Response[src]

Auto Trait Implementations

impl RefUnwindSafe for Response

impl !Send for Response

impl !Sync for Response

impl Unpin for Response

impl UnwindSafe for Response

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.