[−][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::bindings::HttpResponse; use azure_functions::http::Status; let response: HttpResponse = HttpResponse::build() .status(Status::InternalServerError) .into(); 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
use azure_functions::bindings::HttpResponse; let value = "custom header value"; let response: HttpResponse = HttpResponse::build() .header("X-Custom-Header", value) .into(); 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::bindings::HttpResponse; use azure_functions::http::{Body, Status}; let message = "The resouce was created."; let response: HttpResponse = HttpResponse::build() .status(Status::Created) .body(message) .into(); assert_eq!(response.status(), Status::Created); assert_eq!( response.body().as_str().unwrap(), message );
Trait Implementations
impl Default for ResponseBuilder
[src]
fn default() -> ResponseBuilder
[src]
impl From<ResponseBuilder> for HttpResponse
[src]
fn from(builder: ResponseBuilder) -> Self
[src]
impl Debug for ResponseBuilder
[src]
Auto Trait Implementations
impl Send for ResponseBuilder
impl Sync for ResponseBuilder
Blanket Implementations
impl<T> From for T
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
🔬 This is a nightly-only experimental API. (
try_from
)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> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
🔬 This is a nightly-only experimental API. (
try_from
)The type returned in the event of a conversion error.