File tree Expand file tree Collapse file tree 1 file changed +9
-13
lines changed
actionpack/lib/action_dispatch/middleware Expand file tree Collapse file tree 1 file changed +9
-13
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,13 @@ def initialize(message, original_exception)
1313 end
1414 end
1515
16- DEFAULT_PARSERS = { Mime ::JSON => :json }
16+ DEFAULT_PARSERS = {
17+ Mime ::JSON => lambda { |raw_post |
18+ data = ActiveSupport ::JSON . decode ( raw_post )
19+ data = { :_json => data } unless data . is_a? ( Hash )
20+ Request ::Utils . deep_munge ( data ) . with_indifferent_access
21+ }
22+ }
1723
1824 def initialize ( app , parsers = { } )
1925 @app , @parsers = app , DEFAULT_PARSERS . merge ( parsers )
@@ -33,20 +39,10 @@ def parse_formatted_parameters(env)
3339
3440 return false if request . content_length . zero?
3541
36- strategy = @parsers [ request . content_mime_type ]
42+ strategy = @parsers . fetch ( request . content_mime_type ) { return false }
3743
38- return false unless strategy
44+ strategy . call ( request . raw_post )
3945
40- case strategy
41- when Proc
42- strategy . call ( request . raw_post )
43- when :json
44- data = ActiveSupport ::JSON . decode ( request . raw_post )
45- data = { :_json => data } unless data . is_a? ( Hash )
46- Request ::Utils . deep_munge ( data ) . with_indifferent_access
47- else
48- false
49- end
5046 rescue => e # JSON or Ruby code block errors
5147 logger ( env ) . debug "Error occurred while parsing request parameters.\n Contents:\n \n #{ request . raw_post } "
5248
You can’t perform that action at this time.
0 commit comments