How to receive a JSON object with Rack

后端 未结 3 696
臣服心动
臣服心动 2021-01-02 23:35

I have a very simple Ruby Rack server, like:

app = Proc.new do |env| 
  req = Rack::Request.new(env).params
  p req.inspect 
  [200, { \'Content-Type\' =>         


        
3条回答
  •  生来不讨喜
    2021-01-03 00:05

    It seems that I'm supposed to use something like:

    msg = JSON.parse env['rack.input'].read 
    

    Then just use params in the msg hash.

    At least it worked for me this way.

提交回复
热议问题