Skip to content

Instantly share code, notes, and snippets.

@robertsosinski
Created December 4, 2010 19:51
Show Gist options
  • Save robertsosinski/728429 to your computer and use it in GitHub Desktop.
Save robertsosinski/728429 to your computer and use it in GitHub Desktop.
Short Stack: A simple ruby stack server.
require 'rubygems'
require 'rack'
class Object
def webapp
class << self
define_method :call do |env|
meth, *attrs = env['PATH_INFO'].split('/').reject(&:empty?)
[200, {}, [send(meth, *attrs).to_s]]
end
end
self
end
end
Rack::Handler::WEBrick.run [].webapp, :Port => 9292
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment