Warp param reorder easily?

Hi Guys,

is there any way, to reorder the params easily?

I want to have a common param order in my handlers (userid, dbs.., then params), but when I have a path param, I need to have the warp::path::param() first.

My issue:

let get_all = warp::path!("all").and()......and_then();

let get_by_id = warp::path::param()...and()...and_then();

let profile = warp::path!("profile" / ..).and(get_all.or(get_by_id));


localhost/profile/all => get_all part
localhost/profile/demouser => get_by_id part, where my demouser is the String param

So in my get_by_id part, I have no path parts left, only my param - here the id: String -. I could place the path::param() in the chain later, but in that case how should I start my chain? A cannot use empty path, like warp::path!(""), or warp::path("").

But I cannot find any easy way to reorder my params.

Any idea?
Thank you in advance!

Couldn't you do something along the lines of .map(|a, b, c| (c, b, a)).untuple_one()? Varying the number and order of parameters as necessary, of course.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.