use std::ops::Deref; use axum::extract::FromRequest; use axum::http::{self, Request}; use async_trait::async_trait; use serde::de::DeserializeOwned; pub struct Qs(pub T); impl Deref for Qs { type Target = T; fn deref(&self) -> &Self::Target { &self.0 } } #[async_trait] impl FromRequest for Qs where // these bounds are required by `async_trait` B: Send + 'static, S: Send + Sync, T: DeserializeOwned { type Rejection = http::StatusCode; async fn from_request(req: Request, _state: &S) -> Result { let query = req.uri().query().unwrap(); Ok(Self(serde_qs::from_str(query).unwrap())) } }