[][src]Struct wasm_service::Response

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(&mut self, bytes: &[u8]) -> &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) -> &Vec<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_unset(&self) -> bool[src]

True if the response has not been filled in (none of status(), text() or body() has been called). 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 this assigned.

Trait Implementations

impl Debug for Response[src]

impl Default for Response[src]

Auto Trait Implementations

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> 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.