-
Notifications
You must be signed in to change notification settings - Fork 125
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
New implementation of Content-Type and Accept header route matchers #424
Conversation
Codecov Report
@@ Coverage Diff @@
## master #424 +/- ##
==========================================
+ Coverage 83.05% 83.41% +0.36%
==========================================
Files 106 106
Lines 5027 5156 +129
==========================================
+ Hits 4175 4301 +126
- Misses 852 855 +3
Continue to review full report at Codecov.
|
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 looks fantastic. I've created a couple issues around respecting q
parameters, and updating the examples, but I'd rather come closer to the conneg spec than block on perfection.
Well, as I understand the task of the accept header matcher is to see whether there is a match, but has no way to inform the handler as to what quality that match is. Even worse, when a handler has several types it can produce, there is currently no way the matcher can inform the handler which of the types actually produces that match. This is most certainly an issue but sounds like it can't (currently) be solved through a route matcher. Also, I have kept your documentation on both matcher, although the code contained in them reads more as a test than as a usage example. Let me know if you'd like to see this changed. |
I just caught a case I hadn't considered yet and pushed a fix for it. |
@msrd0 I have a small question. This is just for matching, right? So, the router looks for matches and if the route doesn't match because of this, it would check other routes and at the end returns 404. But not 406 or 415. Or am I mistaken? |
@pksunkara Well, I guess the idea is for gotham to return the |
I have reimplemented the Content-Type and Accept header matchers to suit more advanced needs. This includes a fix for #381. Both now use a
HashMap
for efficient lookup and alsoThe Accept matcher
*/*
as a wildcard, but also types with subtype-wildcards likeimage/*
charset=utf-8
as they are not supposed to be part of the Accept header, and conflict with the list syntax as both use commas as separatorsThe Content-Type matcher
text/plain; charset=utf-8
is considered a match whentext/plain
was expected, however,text/plain; charset=utf-8
is not a match iftext/plain; charset=us-ascii
was expectedAlso, I have added public re-exports in their respective super mod for
ContentTypeHeaderRouteMatcher
andRouteNonMatch
to simplify user code.