about summary refs log tree commit homepage
path: root/lib/mongrel.rb
diff options
context:
space:
mode:
authorzedshaw <zedshaw@19e92222-5c0b-0410-8929-a290d50e31e9>2006-04-04 05:24:55 +0000
committerzedshaw <zedshaw@19e92222-5c0b-0410-8929-a290d50e31e9>2006-04-04 05:24:55 +0000
commitd649d856eb957150088a0bb5b947da8f75042405 (patch)
tree335886f830e45e465bb2882d9e656fdbc77757cb /lib/mongrel.rb
parent08b5169a10ebcc11d9561b0eec26657917ef54fd (diff)
downloadunicorn-d649d856eb957150088a0bb5b947da8f75042405.tar.gz
git-svn-id: svn+ssh://rubyforge.org/var/svn/mongrel/trunk@144 19e92222-5c0b-0410-8929-a290d50e31e9
Diffstat (limited to 'lib/mongrel.rb')
-rw-r--r--lib/mongrel.rb12
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/mongrel.rb b/lib/mongrel.rb
index 7832ea2..78aad73 100644
--- a/lib/mongrel.rb
+++ b/lib/mongrel.rb
@@ -524,14 +524,20 @@ module Mongrel
     # Simply registers a handler with the internal URIClassifier.  When the URI is
     # found in the prefix of a request then your handler's HttpHandler::process method
     # is called.  See Mongrel::URIClassifier#register for more information.
-    def register(uri, handler)
+    #
+    # If you set in_front=true then the passed in handler will be put in front in the list.
+    def register(uri, handler, in_front=false)
       script_name, path_info, handlers = @classifier.resolve(uri)
 
       if not handlers
         @classifier.register(uri, [handler])
       else
         if path_info.length == 0 or (script_name == Const::SLASH and path_info == Const::SLASH)
-          handlers << handler
+          if in_front
+            handlers.unshift(handler)
+          else
+            handlers << handler
+          end
         else
           @classifier.register(uri, [handler])
         end
@@ -662,7 +668,7 @@ module Mongrel
     # * :handler => Handler to use for this location.
     def uri(location, options={})
       ops = resolve_defaults(options)
-      @listener.register(location, ops[:handler])
+      @listener.register(location, ops[:handler], in_front=ops[:in_front])
     end