-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Implementing HTTP 405 if HTTP method doesn't match with required by the route #1276
Conversation
It looks like the tests are failing due to a UI mismatch almost certainly caused by differing versions of rustc. Check that your nightly compiler is up to date as this is what the CI will use. Once it is, you should get the same failures locally. |
CI has been failing on @Drunpy, if you rebase your branch on top of the latest |
Ready for review ✔️ @jebrosen |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Drat, I should have looked at this earlier so I could notice the rustfmt
. Thanks for keeping those in separate commits though - that should make it easier to separate those changes out again.
If I'm reading right, the bulk of the change is to have the router not use method
as a filter when finding matching routes, and to instead handle method mismatch one level up in Rocket::route
. The overall approach seems reasonable, but I only have a fuzzy understanding of the routing code and would prefer to have a confirmation from @SergioBenitez before doing a thorough review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is incredibly difficult to review with all of the formatting changes. Please resubmit a PR without any formatting changes to existing code, and if possible, follow the existing style where you can.
However, I'd like to note the following: at a very high level, I'm for this change. My concern is the performance impact that this will have. It's very nice to be able to filter by method: it means we use it as a prefix. We should not remove this from the router. At worst, we should simply iterate through all possible methods, checking to see if there's a match, in case no route was found. This means we take the performance hit only if there's no match initially.
This PR purpose is to meet RFC 7231 sec6.6.5 and #1224