class Async::HTTP::Middleware::Builder
def initialize(default_app = NotFound, &block)
def initialize(default_app = NotFound, &block) @use = [] @app = default_app instance_eval(&block) if block_given? end
def run(app)
def run(app) @app = app end
def to_app
def to_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