Rack: call handler by name: "thin" -> Rack::Handler::Thin etc.

Language: Ruby

require "rubygems"
require "rack"

def run(server)
  require server
  s = Rack::Handler.const_get("#{server.capitalize}")
  app = proc {|env| [200, {"Content-Type" => "text/plain"}, "hello"]}
  s.run(app,:Host => '127.0.0.1', :Port => 2323)
end

run "thin"
# run "mongrel"
Reveal More
Added over 2 years ago by Twitterprofilephoto_normal zh