matchit
matchit copied to clipboard
CatchAll(/*) don't works
Hi. I need a catch all route /*, but I don't care params.
#[test]
fn test_route_path_match() {
let mut router = Router::new();
// works
router.insert("/{*p}", "Catch All Workaround").unwrap();
let matched = router.at("/endpoints/foo/bar").unwrap();
assert_eq!(*matched.value, "Catch All Workaround");
// panic
let mut router = Router::new();
router.insert("/*", "Catch All").unwrap();
let matched = router.at("/endpoints/foo/bar").unwrap();
assert_eq!(*matched.value, "Catch All");
}
/* is not supported syntax, all parameters must have a name. Is there a reason you don't want to provide a name?
I don't use params, just want to catch all
I suppose /{*} is reasonable but I'd suggest you use a placeholder name for now as this is relatively low priority.
One use case of this pattern is for simple nesting of router where a /foo/{*} or foo/* will catch both /foo/ and foo/{*p}. I'm using it in my web framework so I can write Router::new().insert("/foo", Router::new())