bronzerde_axum 0.1.5

`axum` extractors built on `bronzerde` to improve error responses
Documentation
//! Types to represent a problem detail error response.
//!
//! See [RFC 9457](https://www.rfc-editor.org/rfc/rfc9457.html) for more details.
use http::StatusCode;
use krabby_details::{ProblemDetails, ValidationErrors};

pub(crate) struct InvalidRequest(ProblemDetails<ValidationErrors>);

impl InvalidRequest {
    pub(crate) fn new(errors: ValidationErrors) -> Self {
        Self(ProblemDetails {
            type_: "invalid_request".into(),
            status: Self::status().as_u16(),
            title: "The request is invalid".into(),
            extensions: Some(errors),
            detail: "The request is either malformed or doesn't match the expected schema".into(),
        })
    }

    pub(crate) fn status() -> StatusCode {
        StatusCode::BAD_REQUEST
    }

    pub(crate) fn into_inner(self) -> ProblemDetails<ValidationErrors> {
        self.0
    }
}

impl axum_core::response::IntoResponse for InvalidRequest {
    fn into_response(self) -> axum_core::response::Response {
        self.into_inner().into_response()
    }
}