class Rack::NestedParams
Rack
middleware for parsing POST/PUT body data into nested parameters
Constants
- CONTENT_TYPE
- FORM_HASH
- FORM_INPUT
- FORM_VARS
- POST_BODY
- URL_ENCODED
supported content type
Public Class Methods
new(app)
click to toggle source
# File lib/rack/contrib/nested_params.rb 18 def initialize(app) 19 @app = app 20 end
Public Instance Methods
call(env)
click to toggle source
# File lib/rack/contrib/nested_params.rb 22 def call(env) 23 if form_vars = env[FORM_VARS] 24 Rack::Utils.parse_nested_query(form_vars) 25 elsif env[CONTENT_TYPE] == URL_ENCODED 26 post_body = env[POST_BODY] 27 env[FORM_INPUT] = post_body 28 env[FORM_HASH] = Rack::Utils.parse_nested_query(post_body.read) 29 post_body.rewind 30 end 31 @app.call(env) 32 end