Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What type of PR is this? (check all applicable)
Description
Address Issue #751 by using method mismatch flag in
Route.Match()
The flag allows
Route.Match()
to returnMethodNotAllowed (405)
from an earlier mismatch instead of returningNotFound (404)
from a later mismatch (refer to example from #751).For nested endpoints,
The following results show some edge cases:
PUT /v1/foo?id=1
returns405
(match second endpoint, desired behavior)GET /v1/foo?id=abc
returns404
(match second endpoint, 400 on second endpoint preferred)POST /v1/foo?id=abc
returns200
(match first endpoint, 405 on second endpoint might be preferred)POST /v1/foo?id=1
returns200
(match first endpoint, 405 on second endpoint might be preferred)PUT /v1/foo
returns404
(match second endpoint, 405 on first endpoint preferred)GET /v1/foo
returns404
(match second endpoint, 400 on first or 405 on second preferred)These edge cases can be partially resolved(?) by declaring endpoints in descending order of specificity.
PUT /v1/foo?id=1
returns405
(match first endpoint, desired behavior)GET /v1/foo?id=abc
returns405
(match second endpoint, 400 on first endpoint preferred)POST /v1/foo?id=abc
returns200
(match second endpoint, 405 on first endpoint might be preferred)POST /v1/foo?id=1
returns200
(match second endpoint, 405 on first endpoint might be preferred)PUT /v1/foo
returns405
(match second endpoint, desired behavior)GET /v1/foo
returns405
(match second endpoint, 400 on first endpoint might be preferred)Related Tickets & Documents
Added/updated tests?
Run verifications and test
make verify
is passingmake test
is passing