Class: Oxy::CustomHeaders

Inherits:
Object
  • Object
show all
Defined in:
lib/oxy/middleware/custom_headers.rb

Overview

Simple middleware to set custom http headers

Instance Method Summary collapse

Constructor Details

#initialize(app, options) ⇒ CustomHeaders

Returns a new instance of CustomHeaders.



5
6
7
# File 'lib/oxy/middleware/custom_headers.rb', line 5

def initialize(app, options)
  @app, @custom_headers = app, load_from_file(options)
end

Instance Method Details

#call(env) ⇒ Object



9
10
11
12
13
14
# File 'lib/oxy/middleware/custom_headers.rb', line 9

def call(env)
  response = @app.call(env)
  headers = Rack::Utils::HeaderHash.new(response[1])
  response[1] = headers.merge(@custom_headers)
  response
end