summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Pedersen <david.pdrsn@gmail.com>2023-01-07 20:17:13 +0100
committerGitHub <noreply@github.com>2023-01-07 13:17:13 -0600
commit939c29788233f7b3bcd88035662c059e51a2b2cd (patch)
tree27a090e5b159cfe509b514e92bf6fbbe2d1316d3
parent4a0552242ba42aff2b8dbf96fabe331a8c879327 (diff)
Update to axum 0.6.0 (#73)
-rw-r--r--Cargo.toml2
-rw-r--r--src/axum.rs14
2 files changed, 9 insertions, 7 deletions
diff --git a/Cargo.toml b/Cargo.toml
index d9dab35..98aee5b 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -22,7 +22,7 @@ serde = "1.0"
thiserror = "1.0"
tracing = { version = "0.1", optional = true }
warp-framework = { package = "warp", version = "0.3", default-features = false, optional = true }
-axum-framework = { package = "axum", version = "0.5", default-features = false, optional = true }
+axum-framework = { package = "axum", version = "0.6", default-features = false, optional = true }
[dev-dependencies]
chrono = { version = "0.4", features = ["serde"] }
diff --git a/src/axum.rs b/src/axum.rs
index 90b69b8..2638b3c 100644
--- a/src/axum.rs
+++ b/src/axum.rs
@@ -10,7 +10,7 @@ use crate::de::Config as QsConfig;
use crate::error::Error as QsError;
use axum::{
- extract::{Extension, FromRequest, RequestParts},
+ extract::{Extension, FromRequestParts},
http::StatusCode,
response::{IntoResponse, Response},
BoxError, Error,
@@ -69,20 +69,22 @@ impl<T: std::fmt::Debug> std::fmt::Debug for QsQuery<T> {
}
#[axum::async_trait]
-impl<T, B> FromRequest<B> for QsQuery<T>
+impl<T, S> FromRequestParts<S> for QsQuery<T>
where
T: serde::de::DeserializeOwned,
- B: std::marker::Send,
{
type Rejection = QsQueryRejection;
- async fn from_request(req: &mut RequestParts<B>) -> Result<Self, Self::Rejection> {
- let Extension(qs_config) = Extension::<QsQueryConfig>::from_request(req)
+ async fn from_request_parts(
+ parts: &mut axum::http::request::Parts,
+ state: &S,
+ ) -> Result<Self, Self::Rejection> {
+ let Extension(qs_config) = Extension::<QsQueryConfig>::from_request_parts(parts, state)
.await
.unwrap_or_else(|_| Extension(QsQueryConfig::default()));
let error_handler = qs_config.error_handler.clone();
let config: QsConfig = qs_config.into();
- let query = req.uri().query().unwrap_or_default();
+ let query = parts.uri.query().unwrap_or_default();
match config.deserialize_str::<T>(query) {
Ok(value) => Ok(QsQuery(value)),
Err(err) => match error_handler {