-
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
Implement Accept weights #426
Comments
I'm happy to help with this issue, however, I don't have a clear picture of what you are trying to acchieve. I guess this is what came to my mind after thinking about this for a while:
I guess my only use case right now is to allow modern browsers to use modern image types yet keep support for older browsers (basically the example in 2). However, I have never actually attempted to do this, neither with gotham or any other framework. Might be interesting to look at how other frameworks handle this. |
One fresh look here: a very reasonable place for a consumer app to handle Accept is in IntoRespone implementations. On the other hand, it's possible that different content types would require significantly different processing. I'm going to suggest that we break out to separate issues: Simpler: a middleware to inject a q-param sorted list of content types out of the Accept header, so that IntoResponse implementers can find the first type they can represent as a general pattern. More complex: a kind of Accept router - something like setting a scope, and then matching only on accept headers, but such that the q-param is honored. I'm also noting that it seems to me that the easiest way to add an AcceptRouterMatcher is with add_route_matcher, and I wonder if it would be worth looking at defining traits like @gotham-rs/gotham-core Looking for opinions on each of those thoughts. I'll likely create the sorted Accept list issue later today. |
I think there are several places where accessing the Accept header makes sense. If you want to switch between json and xml, you could easily do that in IntoResponse, however, if you want to load a different file ( Nevertheless, I think we need some kind of match quality "feedback" from the matcher, otherwise having one route with different accept header matchers, at least when used from a brower (that almost always adds a |
As of #424 we can check for multiple types in an Accept header, but currently ignore client
q
parameters for selecting a response.Gotham should respect the quality parameter and provide a response type as per https://tools.ietf.org/html/rfc7231#section-5.3
The text was updated successfully, but these errors were encountered: