[−][src]Struct tide::ResponseBuilder
Response Builder
Provides an ergonomic way to chain the creation of a response. This is generally accessed through Response::builder
Example
let mut response = Response::builder(203) .body("body") .content_type(mime::HTML) .header("custom-header", "value") .build(); assert_eq!(response.take_body().into_string().await.unwrap(), "body"); assert_eq!(response.status(), StatusCode::NonAuthoritativeInformation); assert_eq!(response["custom-header"], "value"); assert_eq!(response.content_type(), Some(mime::HTML));
Implementations
impl ResponseBuilder
[src]
pub fn build(self) -> Response
[src]
Returns the inner Response
pub fn header(
self,
key: impl Into<HeaderName>,
value: impl ToHeaderValues
) -> Self
[src]
self,
key: impl Into<HeaderName>,
value: impl ToHeaderValues
) -> Self
Sets a header on the response.
let response = Response::builder(200).header("header-name", "header-value").build(); assert_eq!(response["header-name"], "header-value");
pub fn content_type(self, content_type: impl Into<Mime>) -> Self
[src]
Sets the Content-Type header on the response.
let response = Response::builder(200).content_type(mime::HTML).build(); assert_eq!(response["content-type"], "text/html;charset=utf-8");
pub fn body(self, body: impl Into<Body>) -> Self
[src]
Sets the body of the response.
let mut response = Response::builder(200).body(json!({ "any": "Into<Body>"})).build(); assert_eq!(response.take_body().into_string().await.unwrap(), "{\"any\":\"Into<Body>\"}");
Trait Implementations
impl Debug for ResponseBuilder
[src]
impl Into<Response> for ResponseBuilder
[src]
Auto Trait Implementations
impl !RefUnwindSafe for ResponseBuilder
impl Send for ResponseBuilder
impl Sync for ResponseBuilder
impl Unpin for ResponseBuilder
impl !UnwindSafe for ResponseBuilder
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,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> Sealed<T> for T where
T: ?Sized,
T: ?Sized,
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.
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>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,