Skip to content

Commit 5c91516

Browse files
committed
Merge branch 'release/v0.1.1'
2 parents de53d0a + 16815c2 commit 5c91516

File tree

3 files changed

+12
-16
lines changed

3 files changed

+12
-16
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "axum-validated-extractors"
3-
version = "0.1.0"
3+
version = "0.1.1"
44
edition = "2024"
55
description = "A collection of validated extractors for Axum that automatically validate the extracted data using the validator crate"
66
license = "MIT"

src/lib.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff 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
}

tests/integration_tests.rs

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
use axum_validated_extractors::*;
21
use 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::*;
88
use serde::Deserialize;
99
use tower::ServiceExt;
1010
use 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+
}

0 commit comments

Comments
 (0)