[][src]Struct azure_functions::http::ResponseBuilder

pub struct 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]

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]

impl From<ResponseBuilder> for HttpResponse[src]

impl Debug for ResponseBuilder[src]

Auto Trait Implementations

Blanket Implementations

impl<T> From for T[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

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.

impl<T> Erased for T