end def call env @app.call(env) end end class Mware1 def call env [200, {'content-type' => 'text/html'}, ["Hello Mware1"]] end end app = Proc.new do | env | Mware.new(Mware1.new).call(env) end
'/index' do run Proc.new do | env | [200, {'Content-Type' => 'text/html'}, ['Index']] end end run Proc.new do | env | [200, {'Content-Type' => 'text/html'}, ['Root']] end end Rack::Handler::WEBrick.run app
map '/index' do # ... map '/1' do run Proc.new do | env | [200, {'Content-Type' => 'text/html'}, ['Index 1 ']] end end end # ... end Rack::Handler::WEBrick.run app
def call env [200, {'Content-Type' => 'text/html'}, [@index]] end end require 'rack' app = Rack::Builder.new do use Rack::CommonLogger run Basic.new end Rack::Handler::WEBrick.run app
name @name = name @template = File.read('./index.erb') end def render ERB.new(@template, 0, "", "@rendered_html").result binding self end def call app [200, {'Content-Type' => 'text/html'}, [render.rendered_html]] end end