Last active
December 29, 2015 01:38
-
-
Save tkfm-yamaguchi/7594061 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rack' | |
# Because String#each has taken away since RUBY_VERSION >= 1.9, | |
# Rack::BodyProxy#each causes error ( and when 'use Rakc::CommonLogger' ). | |
# This is the monkey patch to fix it. | |
class String | |
def each(*args, &block) | |
each_line *args, &block | |
end | |
end | |
# http://m.onkey.org/ruby-on-rack-2-the-builder | |
builder = Rack::Builder.new do | |
use Rack::CommonLogger | |
run ->(env) { [200, {"Content-Type" => "text/html"}, env.inspect] } | |
map '/version' do | |
run ->(env) { [200, {"Content-Type" => "text/html"}, "infinity 0.1"] } | |
end | |
end | |
Rack::Handler::Thin.run builder, :Port => 9292 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment