Permalink
Browse files

Initial functionality

  • Loading branch information...
1 parent 4d5d593 commit 7fb045e99d58f6e1e22cda7d279d8f79d5c89bbe @soffes committed Jun 21, 2010
Showing with 39 additions and 0 deletions.
  1. +3 −0 Changelog.markdown
  2. +7 −0 Readme.markdown
  3. +13 −0 access_control.gemspec
  4. +1 −0 init.rb
  5. +15 −0 lib/access_control.rb
View
@@ -0,0 +1,3 @@
+0.0.1 (Jun 20, 2010)
+
+* Initial release
View
@@ -0,0 +1,7 @@
+# Access Control
+
+Access-Control headers are important. If you are doing stuff like embedding fonts with @font-face and you want to use them on another domain than your app, it won't work in several browsers (Firefox being the main one). This gem provides some middleware to solve this. Simply include it in any environments you want Access Control do it's thing like this:
+
+ config.middleware.insert_before ActionDispatch::Static, "AccessControl::Middleware"
+
+Currently all of the options are predefined. Eventually, I'd like to add a way to provide more fine-grain control.
View
@@ -0,0 +1,13 @@
+Gem::Specification.new do |s|
+ s.name = "access_control"
+ s.version = "0.0.1"
+ s.author = "Sam Soffes"
+ s.email = "sam@samsoff.es"
+ s.homepage = "http://github.com/samsoffes/access_control"
+ s.summary = "Easily mange Access-Control headers."
+ s.description = "Easily mange Access-Control headers."
+ s.platform = Gem::Platform::RUBY
+
+ s.files = Dir["{lib}/**/*", "[A-Z]*", "init.rb"]
+ s.require_path = "lib"
+end
View
@@ -0,0 +1 @@
+require "access_control"
View
@@ -0,0 +1,15 @@
+module AccessControl
+ class Middleware
+ def initialize app
+ @app = app
+ end
+
+ def call env
+ res = @app.call(env)
+ res[1]["Access-Control-Allow-Origin"] = "*"
+ res[1]["Access-Control-Allow-Methods"] = "POST, GET, PUT, DELETE, OPTIONS"
+ res[1]["Access-Control-Allow-Headers"] = "X-PINGOTHER "
+ res
+ end
+ end
+end

0 comments on commit 7fb045e

Please sign in to comment.