-
Notifications
You must be signed in to change notification settings - Fork 37
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
Support optional last param #25
Comments
I agree this would be useful to have, I would accept a pull request implementing this :) |
I'll see if I can do this :) |
I've run into a situation where I need an optional parameter, but not at the end. I'm implementing the Docker registry. Docker image tags can be Attempting to add each of the two routes will result in a conflict error. |
Well you can't add optional params in the middle :) That's not how it works. It's not logical. For that case you'd have two routes. |
I tried. But I got a conflict error. is this a bug?
|
That's #13, it would have to be |
Let's suppose you have common handler for REST type API on some resource,
like
/companies/
.So usual request pattern is :
Now all of the work can be done by the same handler , if it knows if
:id
is present.I'm suggesting introduction of optional last param, e.g.
router.insert("/companies/:id?", whatever);
router.insert("/companies/*catch_all?", whatever)
Optional params should be supported only if they are in the route end ( which is obvious ) .
This would be easier than writing double
insert
in code that uses the library.The text was updated successfully, but these errors were encountered: