Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Adding more details to the README #10

Merged
merged 1 commit into from

2 participants

@gottfrois

Hi,

Great gem thank you :)

Here are some details on how to implement the middleware for newbies like me ;) Feel free to update and add it.

Best regards,

@cyu cyu merged commit 82a44e6 into from
@cyu
Owner
cyu commented

Awesome, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 8, 2012
  1. @gottfrois
This page is out of date. Refresh to see the latest.
Showing with 21 additions and 2 deletions.
  1. +21 −2 README.rdoc
View
23 README.rdoc
@@ -13,7 +13,7 @@ http://www.w3.org/TR/access-control/#simple-cross-origin-request-and-actual-r
Install the gem:
gem install rack-cors
-
+
In your Gemfile:
gem 'rack-cors', :require => 'rack/cors'
@@ -31,7 +31,7 @@ You configure Rack::Cors by passing a block to the <tt>use</tt> command:
resource '/file/list_all/', :headers => 'x-domain-token'
resource '/file/at/*',
- :methods => [:get, :post, :put, :delete],
+ :methods => [:get, :post, :put, :delete, :options],
:headers => 'x-domain-token',
:expose => ['Some-Custom-Response-Header']
# headers to expose
@@ -42,3 +42,22 @@ You configure Rack::Cors by passing a block to the <tt>use</tt> command:
resource '/public/*', :headers => :any, :methods => :get
end
end
+
+Put your code in "config/application.rb" on your rails application. For example, this will allow
+from any origins on any resource of your application, methods :get, :post and :options.
+
+ module YourApp
+ class Application < Rails::Application
+
+ # ...
+
+ config.middleware.use Rack::Cors do
+ allow do
+ origins '*'
+ resource '*', :headers => :any, :methods => [:get, :post, :options]
+ end
+ end
+ end
+
+See http://guides.rubyonrails.org/rails_on_rack.html for more details on rack middlewares or
+http://railscasts.com/episodes/151-rack-middleware.
Something went wrong with that request. Please try again.