Struct wasm_framework::Response [−][src]
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]
&mut self,
key: K,
val: V
) -> Result<&mut Self, Error>
Sets a header for this response
pub fn content_type<T: AsRef<str>>(
&mut self,
ctype: T
) -> Result<&mut Self, Error>
[src]
&mut self,
ctype: T
) -> Result<&mut Self, Error>
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
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,