Class: SecureHeaders::Middleware
- Inherits:
-
Object
- Object
- SecureHeaders::Middleware
- Defined in:
- lib/secure_headers/middleware.rb
Instance Method Summary collapse
-
#call(env) ⇒ Object
merges the hash of headers into the current header set.
-
#initialize(app) ⇒ Middleware
constructor
A new instance of Middleware.
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 18 19 20 21 22 23 |
# File 'lib/secure_headers/middleware.rb', line 9 def call(env) req = Rack::Request.new(env) status, headers, response = @app.call(env) # Rack::Headers is available in Rack 3.x and later # So we should pull the headers into that structure if possible if defined?(Rack::Headers) headers = Rack::Headers[headers] end config = SecureHeaders.config_for(req) (headers, override_secure(env, config.)) unless config. == OPT_OUT headers.merge!(SecureHeaders.header_hash_for(req)) [status, headers, response] end |