[−][src]Struct wasm_service::Response
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]
&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) -> &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
Auto Trait Implementations
impl RefUnwindSafe for Response
[src]
impl !Send for Response
[src]
impl !Sync for Response
[src]
impl Unpin for Response
[src]
impl UnwindSafe for Response
[src]
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> 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>,