-
-
Notifications
You must be signed in to change notification settings - Fork 500
Implement #1299: Accept header parsing and content negotiation #1317
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
Conversation
IMO this can be simplified. |
|
|
Should the |
Hm. I think we're running into a bit of an issue here. Conceptually, they should have the same base class. But as you pointed out, On the other hand, there's no reason you can't just implement an |
f5b34a5 to
7690ca1
Compare
|
I moved the code to the dataclasses directory. I also changed it so the interface uses |
6c626eb to
b248f85
Compare
…ation Implement a property to access the parsed value of the 'Accept' header from the request. The returned instance allows iteration in the preferred order of media types. It also provides the 'best_match()' method, that can be used to implement content negotiation by finding the best matching media type for a list of provided types.
b248f85 to
0d99b7f
Compare
0d99b7f to
0bdd950
Compare
|
I cleaned everything up, it should be ready for a final review. I could not get sphinx to reference the |
The references don't work by their absolute path, but rather by how they're set up with autodoc. Since we don't expose this internal module structure to the user, we documented it accordingly, so as far as autodoc is concerned, |
First iteration to implement Accept header parsing and content negotioation. Documentation is missing until the code is stable.
Things to discuss/check
Acceptmight reside in request.py, the other I don't know.MediaTypebe exposed or only used internally?MediaType class
Exposing the results as
stris obviously easier. But when paramters are involved it gets more complicated:In a handler you would do:
which would not match because of the missing parameter.
Implementing parameters might just be too cumbersome and so rarely used that it might be best to ignore them, except for
qand for specificity. Or my logic could be better and the method should only return elements fromprovided_types.PR Checklist
CONTRIBUTING.rst?