如何在轨道上使用机架中间件从json对象构建post params

时间:2017-09-15 19:46:29

标签: ruby-on-rails ruby rack rack-middleware

我收到一个用jwt编码的json对象,在中间件中我想在解码消息之后构建post params

params = JSON.parse(env['rack.input'].read)
json_decoded = decode_data(params['data'], secret_key)
puts "DECODED: #{json_decoded[0]}"
env["rack.input"] = StringIO.new(json_decoded[0].to_s)
>>> CODE HERE

status, headers, response = @app.call(env)
[status, headers, response]

在控制台上

{" name" =>" xyz"," description" =>" xyz"}

ActionDispatch :: Http :: Parameters :: ParseError(822:意外的令牌在' {"名称" =>" xyz","说明&# 34; =>" XYZ"}&#39):

如何建立传递给铁轨的邮政参数

0 个答案:

没有答案