Open utkarshkukreti opened 5 years ago
Ideally, this:
parse(url)
.alt((), |()| Route::Index)
.alt(("posts", query("sort").optional()), |((), sort)| {
Route::PostIndex { sort }
})
.alt(("posts", param()), |((), id)| Route::PostShow {
id,
hash: url.hash.clone(),
})
.value()
would become:
ok(|| Route::Index)
.or(("posts", query("sort").optional()), |sort| {
Route::PostIndex { sort }
})
.or(("posts", param()), |id| Route::PostShow {
id,
hash: url.hash.clone(),
})
.parse(url);
The current parsing API is clunky: the parts which don't have a meaningful return value (which return
()
) are sent to the map function:Warp uses some type system magic to flatten the arguments and filter out the ones which return
()
:https://docs.rs/warp/0.1.9/warp/index.html