Struct azure_functions::bindings::HttpResponseBuilder [−][src]
pub struct HttpResponseBuilder(_);
Represents a builder for HTTP responses.
Methods
impl HttpResponseBuilder
[src]
impl HttpResponseBuilder
pub fn new() -> HttpResponseBuilder
[src]
pub fn new() -> HttpResponseBuilder
Creates a new HttpResponseBuilder
.
pub fn status<S: Into<Status>>(&mut self, status: S) -> &mut Self
[src]
pub fn status<S: Into<Status>>(&mut self, status: S) -> &mut Self
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>>(
&mut self,
name: T,
value: U
) -> &mut Self
[src]
pub fn header<T: Into<String>, U: Into<String>>(
&mut self,
name: T,
value: U
) -> &mut Self
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: Into<Body<'a>>>(&mut self, body: B) -> &mut Self
[src]
pub fn body<'a, B: Into<Body<'a>>>(&mut self, body: B) -> &mut Self
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!( match response.body() { Body::String(s) => s, _ => panic!("unexpected body.") }, message );
Trait Implementations
impl<'a> From<&'a mut HttpResponseBuilder> for HttpResponse
[src]
impl<'a> From<&'a mut HttpResponseBuilder> for HttpResponse
fn from(builder: &'a mut HttpResponseBuilder) -> Self
[src]
fn from(builder: &'a mut HttpResponseBuilder) -> Self
Performs the conversion.
impl Debug for HttpResponseBuilder
[src]
impl Debug for HttpResponseBuilder
Auto Trait Implementations
impl Send for HttpResponseBuilder
impl Send for HttpResponseBuilder
impl Sync for HttpResponseBuilder
impl Sync for HttpResponseBuilder