当我运行curl命令
curl -v -H "Content-type: application/json" -X POST -d '{"name":"abc","id":"12","subject":"my subject"}' http://localhost:9292
要向我的Rack应用程序发送带有数据的POST请求,我的代码打印出{}.这是来自put req.POST()在下面的代码.
为什么打印出{}而不是POST数据?如何正确访问我的Rack应用程序中的POST数据?
require 'json' class Greeter def call(env) req = Rack::Request.new(env) if req.post? puts req.POST() end [200,{"Content-Type" => "application/json"},[{x:"Hello World!"}.to_json]] end end run Greeter.new