[][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::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]

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]

impl Debug for ResponseBuilder[src]

Auto Trait Implementations

Blanket Implementations

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

impl<T> From<T> for T[src]

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

type Error = Infallible

The type returned in the event of a conversion error.

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

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

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

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

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

impl<T> Erased for T