Class: Rack::App::Middlewares::HeaderSetter
- Inherits:
-
Object
- Object
- Rack::App::Middlewares::HeaderSetter
- Defined in:
- lib/rack/app/middlewares/header_setter.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, headers) ⇒ HeaderSetter
constructor
A new instance of HeaderSetter.
Constructor Details
#initialize(app, headers) ⇒ HeaderSetter
Returns a new instance of HeaderSetter.
3 4 5 6 |
# File 'lib/rack/app/middlewares/header_setter.rb', line 3 def initialize(app, headers) @app = app @headers = headers.freeze end |
Instance Method Details
#call(env) ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/rack/app/middlewares/header_setter.rb', line 8 def call(env) status, headers, body = @app.call(env) @headers.each do |header, value| headers[header] ||= value end [status, headers, body] end |