diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/rack/builder.rb | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/rack/builder.rb b/lib/rack/builder.rb index 6f2ab0aa..fa64ae3e 100644 --- a/lib/rack/builder.rb +++ b/lib/rack/builder.rb @@ -109,10 +109,12 @@ module Rack return builder.to_app end + DEFAULT_APP = proc{|env| [404, [], []]} + # Initialize a new Rack::Builder instance. +default_app+ specifies the # default application if +run+ is not called later. If a block # is given, it is evaluted in the context of the instance. - def initialize(default_app = nil, **options, &block) + def initialize(default_app = DEFAULT_APP, **options, &block) @use = [] @map = nil @run = default_app @@ -247,8 +249,8 @@ module Rack # Return the Rack application generated by this instance. 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 |