How to build post params from json object with rack middleware on rails

685 views Asked by At

I receive a json object encoded with jwt, in the middleware i want to build post params after decode the message

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]

on console

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

ActionDispatch::Http::Parameters::ParseError (822: unexpected token at '{"name"=>"xyz", "description"=>"xyz"}'):

how I can build post params for pass to rails

0

There are 0 answers