pub fn create_response<B>(
    state: &State,
    status: StatusCode,
    mime: Mime,
    body: B
) -> Response<Body> where
    B: Into<Body>, 
Expand description

Creates a Response object and populates it with a set of default headers that help to improve security and conformance to best practice.

create_response utilises extend_response, which delegates to set_headers for setting security headers. See set_headers for information about the headers which are populated.

Examples

static BODY: &'static [u8] = b"Hello, world!";

fn handler(state: State) -> (State, Response<Body>) {
    let response = create_response(&state, StatusCode::OK, mime::TEXT_PLAIN, BODY);

    (state, response)
}