diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/extract/json.rs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/extract/json.rs b/src/extract/json.rs index aaf8623..259e890 100644 --- a/src/extract/json.rs +++ b/src/extract/json.rs | |||
| @@ -1,4 +1,7 @@ | |||
| 1 | use axum::extract::{FromRequest, Request, rejection::JsonRejection}; | 1 | use axum::{ |
| 2 | Json, | ||
| 3 | extract::{FromRequest, Request, rejection::JsonRejection}, | ||
| 4 | }; | ||
| 2 | 5 | ||
| 3 | use crate::ErrorResponse; | 6 | use crate::ErrorResponse; |
| 4 | 7 | ||
| @@ -6,13 +9,13 @@ pub struct ApiJson<T>(pub T); | |||
| 6 | 9 | ||
| 7 | impl<S, T> FromRequest<S> for ApiJson<T> | 10 | impl<S, T> FromRequest<S> for ApiJson<T> |
| 8 | where | 11 | where |
| 9 | axum::Json<T>: FromRequest<S, Rejection = JsonRejection>, | 12 | Json<T>: FromRequest<S, Rejection = JsonRejection>, |
| 10 | S: Send + Sync, | 13 | S: Send + Sync, |
| 11 | { | 14 | { |
| 12 | type Rejection = ErrorResponse; | 15 | type Rejection = ErrorResponse; |
| 13 | 16 | ||
| 14 | #[inline] | 17 | #[inline] |
| 15 | async fn from_request(req: Request, state: &S) -> Result<Self, Self::Rejection> { | 18 | async fn from_request(req: Request, state: &S) -> Result<Self, Self::Rejection> { |
| 16 | Ok(Self(axum::Json::<T>::from_request(req, state).await?.0)) | 19 | Ok(Self(Json::from_request(req, state).await?.0)) |
| 17 | } | 20 | } |
| 18 | } | 21 | } |
