class Async::HTTP::Middleware::Builder
def initialize(default_app = nil, &block)
def initialize(default_app = nil, &block) @use = [] @run = default_app instance_eval(&block) if block_given? end
def run(app)
def run(app) @app = app end
def to_app
def to_app app = @use.reverse.inject(app) {|app, use| use.call(app).freeze} end
def use(middleware, *args, &block)
def use(middleware, *args, &block) @use << proc {|app| middleware.new(app, *args, &block)} end