aboutsummaryrefslogtreecommitdiff
path: root/src/extract/json.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/extract/json.rs')
-rw-r--r--src/extract/json.rs9
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 @@
1use axum::extract::{FromRequest, Request, rejection::JsonRejection}; 1use axum::{
2 Json,
3 extract::{FromRequest, Request, rejection::JsonRejection},
4};
2 5
3use crate::ErrorResponse; 6use crate::ErrorResponse;
4 7
@@ -6,13 +9,13 @@ pub struct ApiJson<T>(pub T);
6 9
7impl<S, T> FromRequest<S> for ApiJson<T> 10impl<S, T> FromRequest<S> for ApiJson<T>
8where 11where
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}