-
SummaryI need to provide a uuid variable to my #[tokio::main]
async fn main() {
let router = axum::Router::new()
.route("/test", get(test));
let listener = tokio::net::TcpListener::bind("0.0.0.0:8000").await.unwrap();
axum::serve(listener, router).await.unwrap()
}
pub async fn test(
Query(id): Query<Uuid>
) -> impl IntoResponse {
println!("query value is: {}", id)
} Error: axum version0.8.1 |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
query parameters are essentially key-value pairs. how would you expect |
Beta Was this translation helpful? Give feedback.
-
If your entire query string is just a UUID, you can use If you want to parse #[derive(Deserialize)]
struct TestParams {
id: Uuid,
} and use |
Beta Was this translation helpful? Give feedback.
If your entire query string is just a UUID, you can use
RawQuery
and parse it inside your handler function, or make your own extractor.If you want to parse
id=<uuid>
, create a struct likeand use
Query<TestParams>
.