Skip to content
Browse files

Initial commit

  • Loading branch information...
0 parents commit d797afb4fb5198691c688fb6f4dad6593440b9f8 @guilleiguaran committed Oct 9, 2011
Showing with 36 additions and 0 deletions.
  1. +3 −0 Gemfile
  2. +12 −0 Gemfile.lock
  3. +4 −0 README.md
  4. +17 −0 config.ru
3 Gemfile
@@ -0,0 +1,3 @@
+source :rubygems
+
+gem "rack-mount"
12 Gemfile.lock
@@ -0,0 +1,12 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ rack (1.3.4)
+ rack-mount (0.8.3)
+ rack (>= 1.0.0)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ rack-mount
4 README.md
@@ -0,0 +1,4 @@
+Usage
+======
+
+ bundle exec rackup
17 config.ru
@@ -0,0 +1,17 @@
+require 'rack/mount'
+
+class FooApp
+ def self.call(env)
+ # The id will be in env['rack.routing_args'][:id]
+ [200, {'Content-Type' => 'text/plain'}, [YAML.dump(env)]]
+ end
+end
+
+FooRouter = Rack::Mount::RouteSet.new do |set|
+ set.add_route FooApp, { :request_method => 'GET', :path_info => %r{^/(?<id>[a-z0-9]+)$} }, {}, :foo
+end
+
+# In Rails:
+# mount FooRouter => '/foo'
+# then the route will be '/foo/:id'
+run FooRouter

0 comments on commit d797afb

Please sign in to comment.
Something went wrong with that request. Please try again.