make sure we try looking in th project namespace for middleware first
John Napiorkowski [Fri, 26 Jul 2013 19:21:28 +0000 (15:21 -0400)]
lib/Catalyst.pm
lib/Catalyst/Utils.pm

index 101e673..d6aeb88 100644 (file)
@@ -3067,10 +3067,11 @@ compatible interface, or a coderef, which is assumed to be inlined middleware
 
 =head2 setup_middleware (?@middleware)
 
-Read configuration information stored in configuration key 'psgi_middleware'
-and invoke L</register_middleware> for each middleware prototype found.  See
-under L</CONFIGURATION> information regarding L</psgi_middleware> and how to
-use it to enable L<Plack::Middleware>
+Read configuration information stored in configuration key C<psgi_middleware> or
+from passed @args.
+
+See under L</CONFIGURATION> information regarding C<psgi_middleware> and how
+to use it to enable L<Plack::Middleware>
 
 This method is automatically called during 'setup' of your application, so
 you really don't need to invoke it.
index afa9d32..29a7959 100644 (file)
@@ -453,10 +453,10 @@ sub build_middleware {
           $namespace->new(@init_args) :
             die "Can't load class $namespace";
     } else { ## the string is a partial namespace
-        if(Class::Load::try_load_class("Plack::Middleware::$namespace")) { ## Act like Plack::Builder
-            return "Plack::Middleware::$namespace"->new(@init_args);
-        } elsif(Class::Load::try_load_class("$class::$namespace")) { ## Load Middleware from Project namespace
-            return "$class::$namespace"->new(@init_args);
+        if(Class::Load::try_load_class("$class::$namespace")) { ## Load Middleware from Project namespace
+          return "$class::$namespace"->new(@init_args);
+        } elsif(Class::Load::try_load_class("Plack::Middleware::$namespace")) { ## Act like Plack::Builder
+          return "Plack::Middleware::$namespace"->new(@init_args);
         }
     }