Support for Vec in Query? #433
-
Hi! What I'm looking for is support for one of the following:
I've tried several options like
Of course I can implement it myself using the RawQuery extractor, but it seems like fairly basic usage so I was wondering whether I did something wrong. Cheers! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Oh your right! axum uses serde_urlencoded for I did a very quick test with struct Qs<T>(T);
#[axum::async_trait]
impl<T> FromRequest for Qs<T>
where
T: serde::de::DeserializeOwned,
{
type Rejection = Infallible;
async fn from_request(req: &mut RequestParts) -> Result<Self, Self::Rejection> {
// TODO: error handling
let query = req.uri().query().unwrap();
Ok(Self(serde_qs::from_str(query).unwrap()))
}
}
async fn handler(Qs(ids): Qs<Input>) {
dbg!(ids);
}
#[derive(serde::Deserialize, Debug)]
struct Input {
ids: Vec<i32>,
} Now I'm wondering if axum should just change to I'm gonna convert this into an issue. |
Beta Was this translation helpful? Give feedback.
See #434.