Robust Params Parser by Infopark Infopark

Params parser Rack middleware able to handle parsing errors. Temporary workaround for rails/rails#7424

For Rails 3 only. As of Rails 4 this workaround is obsolete.

Installation

  # In your Gemfile
  gem 'robust_params_parser'

  # In your config/application.rb
  config.middleware.swap ActionDispatch::ParamsParser, ::RobustParamsParser, {}

Usage

Just make a POST with Content-Type 'application/json' and an invalid JSON as payload, which will result in a 400 status code and an empty body response.

Caveats

Only works if you're using MultiJson.

License

LGPG-3.0 License. Copyright 2013 Infopark AG. http://www.infopark.com