Added query parameters.

This commit is contained in:
2026-09-26 20:19:06 +02:00
parent 9279258ff1
commit 859ae71c51
12 changed files with 172 additions and 20 deletions
+24
View File
@@ -0,0 +1,24 @@
use axum::extract::FromRequestParts;
use serde::de::DeserializeOwned;
use crate::error::AppError;
pub struct Query<T>(pub T);
impl<T, S> FromRequestParts<S> for Query<T>
where
T: DeserializeOwned + Send,
S: Send + Sync,
{
type Rejection = AppError;
async fn from_request_parts(
parts: &mut axum::http::request::Parts,
state: &S,
) -> Result<Self, Self::Rejection> {
axum::extract::Query::<T>::from_request_parts(parts, state)
.await
.map(|axum::extract::Query(value)| Self(value))
.map_err(|rejection| AppError::BadRequest(rejection.body_text()))
}
}