Skip to content

Iterating queryparams? #444

Answered by sunli829
jakob-lilliemarck asked this question in Q&A
Discussion options

You must be logged in to vote

so easy: 🙂

let app = Route::new()
        .at("/hello/:name", get(hello))
        .around(|ep, request| async move {
            // parse the query params
            let query_params = request.params::<Vec<(String, String)>>()?;
            for (name, value) in query_params {
                // do something...
                println!("{}: {}", name, value);
            }
            ep.call(request).await // call the next handler
        })
        .with(Tracing);

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@jakob-lilliemarck
Comment options

Answer selected by jakob-lilliemarck
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants