summary refs log tree commit
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2013-11-06 03:02:48 +0000
committerEric Wong <normalperson@yhbt.net>2013-11-06 03:08:38 +0000
commitfd023bafed0ad97e08d15381f35600e3a5b32808 (patch)
tree3bf21330c39c880b79d1256bfa5f9112cd355b41
parentdf1506b0825a096514fcb3821563bf9e8fd52743 (diff)
downloadrack-builder-map-to_app.tar.gz
builder: avoid to_app on every request when using map builder-map-to_app
By calling to_app immediately after initializing the per-map
Rack::Builder instances.  Otherwise, benefits of warmup and web
servers taking advantage of CoW are lost.

This passes tests, and is lightly tested and I have not verified
this for any negative consequences or incompatibilities.
-rw-r--r--lib/rack/builder.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/rack/builder.rb b/lib/rack/builder.rb
index fa3a1ea9..2aa37b68 100644
--- a/lib/rack/builder.rb
+++ b/lib/rack/builder.rb
@@ -157,7 +157,7 @@ module Rack
 
     def generate_map(default_app, mapping)
       mapped = default_app ? {'/' => default_app} : {}
-      mapping.each { |r,b| mapped[r] = self.class.new(default_app, &b) }
+      mapping.each { |r,b| mapped[r] = self.class.new(default_app, &b).to_app }
       URLMap.new(mapped)
     end
   end