draco
draco copied to clipboard
Implement Router URL parsing API like how `warp` does
The current parsing API is clunky: the parts which don't have a meaningful return value (which return ()
) are sent to the map function:
.alt(("posts", query("sort").optional()), |((), sort)| {
Route::PostIndex { sort }
})
Warp uses some type system magic to flatten the arguments and filter out the ones which return ()
:
let hi = warp::path("hello")
.and(warp::path::param())
.and(warp::header("user-agent"))
.map(|param: String, agent: String| {
format!("Hello {}, whose agent is {}", param, agent)
});
https://docs.rs/warp/0.1.9/warp/index.html