-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Description
The latest commit to bring in pull request #136 broke JSON encoded parameters for me.
I couldn't get a good spec working on this, yet when I mounted with Rack and ran a server, I could reproduce. Here's how to reproduce:
- Create
config.ru
require 'multi_json'
require 'grape'
class Foo < Grape::API
post do
params[:cities].map do |c|
c[:city][:name]
end.join(' ')
end
end
run Rack::URLMap.new "/" => Foo- Run the server with
rackup -p 3000 - Open up
irband type
require 'multi_json'
require 'rest-client'
city1 = {:city => {:name => "Dallas"}}
city2 = {:city => {:name => "Austin"}}
parameters = MultiJson.encode({:cities => [city1, city2]})
RestClient.post('http://localhost:3000', parameters)On master, this will throw a Server 500 error.
If you change lib/grape/middleware/formatter.rb line 18 from
env.dup.inject({}){|h,(k,v)| h[k.downcase[5..-1]] = v if k.downcase.start_with?('http_'); h}back to
env.dup.inject({}){|h,(k,v)| h[k.downcase] = v; h}then rerunning will produce the proper output of "Dallas Austin"
Metadata
Metadata
Assignees
Labels
No labels