-
-
Notifications
You must be signed in to change notification settings - Fork 103
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
Allow for identifying 404 vs. 405 #62
Comments
AFAIK the router package does not support this. Looking through the code I think it would drastically change the way things are done to be able to support it. Right now, if the method does not match, then it actually skips the whole path matching. This is a perf improvement because the path matching is the least efficient part. I think (although have not tried) that you could rig up your routes in such a way as you can do this manually, like: router.route('/foo')
.get(getHandler)
.post(postHandler)
.all(function (req, res) {
res.status(405).send();
}); But you would have to be careful that nothing else after was supposed to handle the route. |
Why does it have to be a drastic change? Looking at the source, it seems very simple. You could add a property to |
I am aware now that this would be a breaking change and that isn't ideal. And since the test suite relies heavily on the current support...this could be bigger than expected. But the logic for this seems pretty simple. |
I didn't mean the code change was drastic, rather that the effect of the change would be. Since it is quick I don't see a reason not to submit a PR, but I am not sure I am in support of testing route matching when the method does not match. |
I thought about wrapping this up in a configuration option but after implementing this, there is no way to make it work. For a method/path miss, there is no I'll leave this open for now but if you think it's not worth considering further, I'm cool if you close it. I do think it's a good idea to be able to differentiate between |
On this I agree completely. Sending an |
I'll give the |
LMK if #63 works for you. |
Yep, it worked great! Thanks a ton. |
Whenever
router
fails to match a request, it can be one of two reasons:405
)404
)I cannot seem to figure out a way to differentiate between the two in my
finalhandler
and I was hoping that either someone can point me in the right direction or mayberouter
can be updated to allow for such things.The text was updated successfully, but these errors were encountered: