これを行うのに最適な場所を見つけようとしています。私のミドルウェアは次のようになります:
class Fixer
def initialize app
@app = app
end
def call env
if env["HTTP_ORIGIN"] == "https://where_i_expect_it_to_come_from.com/"
env['rack.input'] = StringIO.new('{"yo":"momma"}') # <-- But this info is not actually written before the call is passed!
end
env['rack.input'].rewind
status, headers, response = @app.call env
return [status, headers, response]
end
end
Rails.application.config.middleware.insert_before ActionDispatch::ParamsParser, Fixer
ここで呼び出しを書き換えても、実際には情報が正しく書き換えられていないようです。バブルアップする前にコンテンツを作成する方法はありますか?