= [], nil, default_app, nil, false instance_eval(&block) if block_given? end def use(middleware, *args, &block) if @map mapping, @map = @map, nil @use << proc { |app| generate_map app, mapping } end @use << proc { |app| middleware.new(app, *args, &block) } end def run(app) @run = app end def call(env) to_app.call(env) end def to_app app = @map ? generate_map(@run, @map) : @run fail "missing run or map statement" unless app app.freeze if @freeze_app app = @use.reverse.inject(app) { |a,e| e[a].tap { |x| x.freeze if @freeze_app } } @warmup.call(app) if @warmup app end