config/initializers/additional_http_headers.rb
class AdditionalHTTPHeaders
def initialize(app)
@app = app
end
def call(env)
status, headers, body = @app.call(env)
additional_headers.each{|k, v| headers[k] = v }
[status, headers, body]
end
private
def additional_headers
{
'x-foo' => 'bar',
}
end
end
Rails.application.config.middleware.insert_before(
ActionDispatch::Cookies, AdditionalHTTPHeaders
)