File tree Expand file tree Collapse file tree 3 files changed +12
-16
lines changed
Expand file tree Collapse file tree 3 files changed +12
-16
lines changed Original file line number Diff line number Diff line change 11[package ]
22name = " axum-validated-extractors"
3- version = " 0.1.0 "
3+ version = " 0.1.1 "
44edition = " 2024"
55description = " A collection of validated extractors for Axum that automatically validate the extracted data using the validator crate"
66license = " MIT"
Original file line number Diff line number Diff line change @@ -339,7 +339,8 @@ where
339339 parts : & mut axum:: http:: request:: Parts ,
340340 state : & S ,
341341 ) -> Result < Self , Self :: Rejection > {
342- let axum:: extract:: Query ( value) = axum:: extract:: Query :: < T > :: from_request_parts ( parts, state) . await ?;
342+ let axum:: extract:: Query ( value) =
343+ axum:: extract:: Query :: < T > :: from_request_parts ( parts, state) . await ?;
343344 Ok ( ValidatedQuery ( validate_and_wrap ( value) ?) )
344345 }
345346}
@@ -356,7 +357,8 @@ where
356357 req : axum:: http:: Request < axum:: body:: Body > ,
357358 state : & S ,
358359 ) -> Result < Self , Self :: Rejection > {
359- let axum:: extract:: Query ( value) = axum:: extract:: Query :: < T > :: from_request ( req, state) . await ?;
360+ let axum:: extract:: Query ( value) =
361+ axum:: extract:: Query :: < T > :: from_request ( req, state) . await ?;
360362 Ok ( ValidatedQuery ( validate_and_wrap ( value) ?) )
361363 }
362364}
Original file line number Diff line number Diff line change 1- use axum_validated_extractors:: * ;
21use axum:: {
3- body:: Body ,
4- routing:: { get, post} ,
52 Router ,
3+ body:: Body ,
64 http:: StatusCode ,
5+ routing:: { get, post} ,
76} ;
7+ use axum_validated_extractors:: * ;
88use serde:: Deserialize ;
99use tower:: ServiceExt ;
1010use validator:: Validate ;
@@ -36,23 +36,17 @@ pub struct QueryInput {
3636
3737// Test handlers
3838#[ axum:: debug_handler]
39- pub async fn json_handler (
40- ValidatedJson ( _input) : ValidatedJson < JsonInput > ,
41- ) -> & ' static str {
39+ pub async fn json_handler ( ValidatedJson ( _input) : ValidatedJson < JsonInput > ) -> & ' static str {
4240 "ok"
4341}
4442
4543#[ axum:: debug_handler]
46- pub async fn form_handler (
47- ValidatedForm ( _input) : ValidatedForm < FormInput > ,
48- ) -> & ' static str {
44+ pub async fn form_handler ( ValidatedForm ( _input) : ValidatedForm < FormInput > ) -> & ' static str {
4945 "ok"
5046}
5147
5248#[ axum:: debug_handler]
53- pub async fn query_handler (
54- ValidatedQuery ( _input) : ValidatedQuery < QueryInput > ,
55- ) -> & ' static str {
49+ pub async fn query_handler ( ValidatedQuery ( _input) : ValidatedQuery < QueryInput > ) -> & ' static str {
5650 "ok"
5751}
5852
@@ -169,4 +163,4 @@ async fn test_invalid_query() {
169163 . unwrap ( ) ;
170164
171165 assert_eq ! ( response. status( ) , StatusCode :: BAD_REQUEST ) ;
172- }
166+ }
You can’t perform that action at this time.
0 commit comments