require "rack" # rack middleware class HogeMidWare def initialize(app) puts "init hoge" @app = app end def call(env) puts "hoge" @app.call(env) end end # rack middleware class FooMidWare def initialize(app) puts "init foo" @app = app end def call(env) puts "foo" @app.call(env) end end # rack application class HomApp def call(env) puts "hom" [200, {"Content-Type" => "text/plain"}, ["hom"]] end end