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.



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

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object

merges the hash of headers into the current header set.



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

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)) unless config.cookies == OPT_OUT
  headers.merge!(SecureHeaders.header_hash_for(req))
  [status, headers, response]
end