[−][src]Struct azure_functions::http::ResponseBuilder
Represents a builder for HTTP responses.
Methods
impl ResponseBuilder
[src]
pub fn new() -> ResponseBuilder
[src]
Creates a new ResponseBuilder
.
pub fn status<S: Into<Status>>(self, status: S) -> Self
[src]
Sets the status for the response.
Examples
use azure_functions::http::Status; let response = ResponseBuilder::new() .status(Status::InternalServerError) .finish(); assert_eq!(response.status(), Status::InternalServerError);
pub fn header<T: Into<String>, U: Into<String>>(self, name: T, value: U) -> Self
[src]
Sets a header for the response.
Examples
let value = "custom header value"; let response = ResponseBuilder::new() .header("X-Custom-Header", value) .finish(); assert_eq!( response .headers() .get("X-Custom-Header") .unwrap(), value );
pub fn body<'a, B>(self, body: B) -> Self where
B: Into<Body<'a>>,
[src]
B: Into<Body<'a>>,
Sets the body of the response.
This will automatically set a Content-Type
header for the response depending on the body type.
Examples
use azure_functions::http::{Body, Status}; let message = "The resouce was created."; let response = ResponseBuilder::new() .status(Status::Created) .body(message) .finish(); assert_eq!(response.status(), Status::Created); assert_eq!( response.body().as_str().unwrap(), message );
pub fn finish(self) -> HttpResponse
[src]
Consumes the builder and returns the HTTP response.
Trait Implementations
impl Default for ResponseBuilder
[src]
fn default() -> ResponseBuilder
[src]
impl Debug for ResponseBuilder
[src]
Auto Trait Implementations
impl Send for ResponseBuilder
impl Sync for ResponseBuilder
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
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<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,