Skip to main content

error_response

Function error_response 

Source
pub fn error_response(
    status: StatusCode,
    message: &str,
    code: &str,
) -> Response<Full<Bytes>>
Expand description

Build a standard error response body and wrap it as a full HTTP response.

ยงExamples

use guardrail_proxy::error::error_response;
use hyper::StatusCode;

let resp = error_response(StatusCode::BAD_REQUEST, "invalid JSON", "bad_request");
assert_eq!(resp.status(), StatusCode::BAD_REQUEST);
assert_eq!(
    resp.headers().get("content-type").unwrap(),
    "application/json"
);