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

Wildcard must be the last pattern in a route but it is not enforced in some cases #333

Closed
adamwasila opened this issue Jul 18, 2018 · 1 comment

Comments

@adamwasila
Copy link

This code runs smoothly although gives unexpected results:

r := chi.NewRouter()
r.Get("/*/this/is/ignored", myHandler())

Problem is that anything past the wildcard seems to be ignored, thus in this example - requesting ANY path prefixed with /test/, eg. /test/blah/blah/blah causes handler to be called.

On the other case, if you simply modify the code:

r := chi.NewRouter()
r.Get("/*/this/is/{not}/ignored", myHandler())

(path with named param and wildcard together), then code simply panics at the startup with clear and meaningful error:

panic: chi: wildcard '*' must be the last pattern in a route, otherwise use a '{param}'

So, what I believe expected behaviour would be to panic consistently in both cases, with exactly same error. Am I right?

pkieltyka added a commit that referenced this issue Jan 8, 2019
@pkieltyka pkieltyka mentioned this issue Jan 8, 2019
5 tasks
@pkieltyka
Copy link
Member

@adamwasila yes thats exactly right, both cases should catch. thanks for noticing and reporting this. I've fixed it in v4

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

No branches or pull requests

2 participants