【发布时间】:2014-03-27 14:47:11
【问题描述】:
我正在努力寻找执行此操作的最佳位置。我的中间件是这样的:
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
似乎即使我在这里重写调用,信息实际上也没有正确重写。有什么想法可以让我的内容在冒泡之前写好?
【问题讨论】:
标签: ruby-on-rails json rack middleware env