class Rack::ResponseHeaders

Allows you to tap into the response headers. Yields a Rack::Utils::HeaderHash of current response headers to the block. Example:

use Rack::ResponseHeaders do |headers|
  headers['X-Foo'] = 'bar'
  headers.delete('X-Baz')
end

Public Class Methods

new(app, &block) click to toggle source
   # File lib/rack/contrib/response_headers.rb
13 def initialize(app, &block)
14   @app = app
15   @block = block
16 end

Public Instance Methods

call(env) click to toggle source
   # File lib/rack/contrib/response_headers.rb
18 def call(env)
19   response = @app.call(env)
20   headers = Utils::HeaderHash.new(response[1])
21   @block.call(headers)
22   response[1] = headers
23   response
24 end