edge badge

ActionDispatch::ParamsParser works for all the requests having any Content-Length (like POST). It takes raw data from the request and puts it through the parser that is picked based on Content-Type header.

In case of any error while parsing data ParamsParser::ParseError is raised.

Namespace
Methods
C
N
Constants
DEFAULT_PARSERS = { Mime::JSON => lambda { |raw_post| data = ActiveSupport::JSON.decode(raw_post) data = {:_json => data} unless data.is_a?(Hash) Request::Utils.normalize_encode_params(data) } }
 
Class Public methods
new(app, parsers = {})

Create a new ParamsParser middleware instance.

The parsers argument can take Hash of parsers where key is identifying content mime type, and value is a lambda that is going to process data.

# File actionpack/lib/action_dispatch/middleware/params_parser.rb, line 33
def initialize(app, parsers = {})
  @app, @parsers = app, DEFAULT_PARSERS.merge(parsers)
end
Instance Public methods
call(env)
# File actionpack/lib/action_dispatch/middleware/params_parser.rb, line 37
def call(env)
  request = Request.new(env)

  parse_formatted_parameters(request, @parsers) do |params|
    request.request_parameters = params
  end

  @app.call(env)
end