Skip to content

Instantly share code, notes, and snippets.

@tkfm-yamaguchi
Last active December 29, 2015 01:38
Show Gist options
  • Save tkfm-yamaguchi/7594061 to your computer and use it in GitHub Desktop.
Save tkfm-yamaguchi/7594061 to your computer and use it in GitHub Desktop.
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