Created
March 24, 2010 21:55
-
-
Save anveo/342874 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Rack | |
class AddAccessControlHeader | |
def initialize app, opts | |
@app = app | |
@extensions = opts | |
end | |
def call(env) | |
response = @app.call(env) | |
headers = Utils::HeaderHash.new(response[1]) | |
ext = env["PATH_INFO"].split(".")[-1] | |
headers["Access-Control-Allow-Origin"] = '*' if @extensions.include?(ext) | |
response[1] = headers | |
response | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment