Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CatchAll(/*) don't works #64

Open
taikulawo opened this issue Nov 7, 2024 · 4 comments
Open

CatchAll(/*) don't works #64

taikulawo opened this issue Nov 7, 2024 · 4 comments
Labels
feature New feature or request

Comments

@taikulawo
Copy link

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");
    }
@ibraheemdev
Copy link
Owner

ibraheemdev commented Nov 7, 2024

/* is not supported syntax, all parameters must have a name. Is there a reason you don't want to provide a name?

@taikulawo
Copy link
Author

I don't use params, just want to catch all

@ibraheemdev ibraheemdev added the feature New feature or request label Nov 7, 2024
@ibraheemdev
Copy link
Owner

I suppose /{*} is reasonable but I'd suggest you use a placeholder name for now as this is relatively low priority.

@fakeshadow
Copy link

fakeshadow commented Nov 11, 2024

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())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants