Class: CSPEasy

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

Instance Method Summary collapse

Constructor Details

#initialize(app, policy = "") ⇒ CSPEasy

Returns a new instance of CSPEasy.



2
3
4
5
# File 'lib/csp_easy.rb', line 2

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

Instance Method Details

#_call(env) ⇒ Object



11
12
13
14
15
# File 'lib/csp_easy.rb', line 11

def _call(env)
  @status, @headers, @response = @app.call(env)
  @headers["X-Content-Security-Policy"] = @policy unless @policy.blank?
  [@status, @headers, self]
end

#call(env) ⇒ Object



7
8
9
# File 'lib/csp_easy.rb', line 7

def call(env)
  dup._call(env)
end

#each(&block) ⇒ Object



17
18
19
# File 'lib/csp_easy.rb', line 17

def each(&block)
  @response.each(&block)
end