matchit
matchit copied to clipboard
Return iterator of matching routes instead of first match
For something like fall-through routing, it would be useful to return an iterator of values that match the route.
An example might be:
let mut router = Router::new();
router.insert("/users/:id", 1);
router.insert("/users/:name", 2);
router.insert("/users/*", 3);
let mut matches = router.at("/users/ari").iter();
assert_eq!(matches.next(), Some(1));
assert_eq!(matches.next(), Some(2));
assert_eq!(matches.next(), Some(3));
assert_eq!(matches.next(), None);
This would be a pretty fundamental change to the router. For fallback routing I was thinking of supporting a much simpler model, where conflicting inserts would return the conflicting value. From there you could handle routing guards, etc. yourself.
That sounds simpler. In my case, we forked matchit and modified it to our needs, so if it's not in the scope of matchit, feel free to close this issue