Skip to content

Instantly share code, notes, and snippets.

@floere
Forked from igrigorik/webapp.rb
Created November 13, 2010 23:57
Show Gist options
  • Save floere/675761 to your computer and use it in GitHub Desktop.
Save floere/675761 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'rack'
class Object
def webapp
def call(env)
func, *attrs = env['REQUEST_PATH'].split('/').reject(&:empty?)
[200, {}, send(func, *attrs)]
end
self
end
end
Rack::Handler::Mongrel.run [].webapp, :Port => 9292
# http://localhost:9292/push/1 -> 1
# http://localhost:9292/push/2 -> 12
# http://localhost:9292/push/2 -> 123
# http://localhost:9292/to_a -> 123
# http://localhost:9292/pop -> 3
# http://localhost:9292/shift -> 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment