Class: Rack::Csp

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/csp.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, policy:) ⇒ Csp

Returns a new instance of Csp.



7
8
9
10
# File 'lib/rack/csp.rb', line 7

def initialize(app, policy:)
  @app = app
  @policy = policy
end

Instance Method Details

#call(env) ⇒ Object



12
13
14
15
16
# File 'lib/rack/csp.rb', line 12

def call(env)
  status, headers, body = @app.call(env)
  headers["Content-Security-Policy"] = @policy
  [status, headers, body]
end