Skip to content
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

Make sure the parameter parsers register API work with overidden mime types. #23816

Merged
merged 3 commits into from Feb 23, 2016

Conversation

rafaelfranca
Copy link
Member

Currently if you want to add a new mime type to an existing type like application/vnd.api+json it will not use the JSON parameter parser.

The reason is that we use the Mime::Type object as the key of the parameter parser hash.

Here is an example of how an application use this behavior.

Mime::Type.unregister :json
Mime::Type.register "application/json", :json, %w(text/x-json application/jsonrequest application/vnd.api+json)

To fix it we changed the parameter parsers internal representation to use the Mime::Type's symbol method.

To not break the existing API, when instantiating the ActionDispatch::ParamsParser we accept Mime::Type instances but we change them to symbols.

meinac and others added 3 commits February 22, 2016 21:22
After registering new `:json` mime type `parsers.fetch` can't find the mime type because new mime type is not equal to old one. Using symbol of the mime type as key on parsers hash solves the problem.

Closes #23766
This will keep our current API working without having the users to
change their codebases.
Also make sure we don't change the global state of our test suite.
rafaelfranca added a commit that referenced this pull request Feb 23, 2016
Make sure the parameter parsers register API work with overidden mime types.
@rafaelfranca rafaelfranca merged commit e729949 into master Feb 23, 2016
@rafaelfranca rafaelfranca deleted the params_parser_api branch February 23, 2016 00:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants