Warning
This post was published 39 days ago. The information described in this article may have changed.
Hi,
I'm trying to get the value of a 'get' parameter on a 'delete' request. I'm receiving the value encoded as it was sent from the client, so axum is not decoding it.
#[derive(Debug, Deserialize)]
struct Params {
k: Option<i64>,
ct: Option<u64>,
s: Option<u32>,
d: Option<char>,
q: Option<String>
}
My 'delete' handler:
async fn delete_handler(Path(method_id): Path<u16>, Query(params): Query<Params>, body: String) -> Response {
println!("delete_handler :: q = {:?}", params.q);
if params.q.is_some() {
// CACHES.remove_by_search(method_id, params.q.unwrap()).await;
}
else {
CACHES.remove_all_by_body(method_id, body).await;
}
StatusCode::OK.into_response()
}
When the delete request is received:
DELETE http://host:port/api/q=%7B%22404%22%3A 12345%7D
I expected to get the decoded result in "params.q":
{"404": 12345}
But "params.q" contains "%7B%22404%22%3A 12345%7D"
What do I need to add to get this parameter directly decoded?
Thanks,
Joan.
3 posts - 2 participants
🏷️ rust_feed