Skip to content

Instantly share code, notes, and snippets.

@anveo
Created March 24, 2010 21:55
Show Gist options
  • Save anveo/342874 to your computer and use it in GitHub Desktop.
Save anveo/342874 to your computer and use it in GitHub Desktop.
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