Class: Rack::AccessControlHeaders
- Inherits:
-
Object
- Object
- Rack::AccessControlHeaders
- Defined in:
- lib/rack/access-control-headers.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, path, origin = "*") ⇒ AccessControlHeaders
constructor
A new instance of AccessControlHeaders.
Constructor Details
#initialize(app, path, origin = "*") ⇒ AccessControlHeaders
Returns a new instance of AccessControlHeaders.
3 4 5 6 7 |
# File 'lib/rack/access-control-headers.rb', line 3 def initialize(app, path, origin = "*") @app = app @path = path @origin = origin end |
Instance Method Details
#call(env) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/rack/access-control-headers.rb', line 9 def call(env) response = @app.call(env) if env["PATH_INFO"].match @path response[1]["Access-Control-Allow-Origin"] = @origin response[1]["Cache-Control"] = "public" response[1]["Expires"] = (Time.now + (60*60*24*365*10)).httpdate end response end |