Class: SecureHeaders::Middleware

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

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Middleware

Returns a new instance of Middleware.



3
4
5
# File 'lib/secure_headers/middleware.rb', line 3

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object

merges the hash of headers into the current header set.



8
9
10
11
12
13
14
15
16
# File 'lib/secure_headers/middleware.rb', line 8

def call(env)
  req = Rack::Request.new(env)
  status, headers, response = @app.call(env)

  config = SecureHeaders.config_for(req)
  flag_cookies!(headers, override_secure(env, config.cookies)) if config.cookies
  headers.merge!(SecureHeaders.header_hash_for(req))
  [status, headers, response]
end