我正在努力寻找最好的地方来做到这一点。我的中间件如下所示:
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
似乎即使我在这里重写调用,信息实际上也没有正确重写。有什么想法可以让我的内容在冒泡之前写出来吗?