-
-
Notifications
You must be signed in to change notification settings - Fork 60
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
Rework routeDispatchTries + endpoint lookup for more intuitive 404/405 responses. #52
Conversation
0caaba0
to
d3825ff
Compare
Fixes com-lihaoyi#51. Prior to this commit, `prepareRouteTries` created a mapping from method-name to DispatchTrie (Map[String, DispatchTrie[…]]). This commit instead creates a DispatchTrie[Map[String, …]], basically an inversion of the previous result. The updated tests in minimalApplication and minimalApplication2 have been updated to cover the differences.
This PR is probably pretty stale by now. Still, it'd be nice to at least get some form of feedback on the hours spent.. |
@megri could you provide a proper PR description of what your change is doing and how it fixes the problem? That would make it much easier to review and merge |
I updated the PR with the commit message of the final commit. There is some cleanup/unrelated commits in the PR as well. I can remove those if so desired. |
@megri looks great, sorry for the delay in getting to this. Have not been on top of maintenance last few months |
This regressed in #52, resulting in both false positives (where a `GET` and a `POST` shared the same route, giving an unnecessary error) and false negatives (where multiple `GET`s sharing the same route failed to create an error). The basic problem was that since combining the various HTTP methods into a single routing trie, the old logic comparing uniqueness/duplication/etc. was no longer correct in the new combined trie. This PR fixes it by doing a `groupBy` to split up the entries in the combined trie by HTTP method, before running essentially the same validation. We augment the test suite, tightening up cask/test/src/test/cask/DispatchTrieTests.scala to make it stricter, checking exact error messages to ensure we get not just any failure but the *correct* failure when the validation code triggers. This should hopefully catch this sort of regression in future.
Prevent cask from responding with 405 for an undefined route.
Fixes #51.
Prior to this commit,
prepareRouteTries
created a mapping frommethod-name to DispatchTrie (Map[String, DispatchTrie[…]]).
This commit instead creates a DispatchTrie[Map[String, …]],
basically an inversion of the previous result.
The updated tests in minimalApplication and minimalApplication2
have been updated to cover the differences.