Make status codes for JsonRejection more precise (#868)

* Fix status codes for `JsonRejection` rejections

Fixes #865

* Apply suggestions from code review

Co-authored-by: Jonas Platte <[email protected]>

Co-authored-by: Jonas Platte <[email protected]>
This commit is contained in:
David Pedersen
2022-03-18 16:53:39 +01:00
committed by GitHub
co-authored by Jonas Platte
parent 33ee55e52c
commit 437fe5b931
5 changed files with 88 additions and 21 deletions
@@ -69,7 +69,7 @@ where
Err(rejection) => {
// convert the error from `axum::Json` into whatever we want
let (status, body): (_, Cow<'_, str>) = match rejection {
JsonRejection::InvalidJsonBody(err) => (
JsonRejection::JsonDataError(err) => (
StatusCode::BAD_REQUEST,
format!("Invalid JSON request: {}", err).into(),
),