Class: SecureHeaders::Middleware

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

Constant Summary collapse

/;\s*secure\s*(;|$)/i.freeze

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Middleware

Returns a new instance of Middleware.



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

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object

merges the hash of headers into the current header set.



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

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

  config = SecureHeaders.config_for(req)
  flag_cookies_as_secure!(headers) if config.secure_cookies
  headers.merge!(SecureHeaders.header_hash_for(req))
  [status, headers, response]
end