From: John Napiorkowski Date: Thu, 1 May 2014 23:49:01 +0000 (-0500) Subject: docs and correct middleware order X-Git-Tag: 5.90064~2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=b11b634514ba61907a4883935f1c83de0926acbd docs and correct middleware order --- diff --git a/Changes b/Changes index 7987fda..b5a8105 100644 --- a/Changes +++ b/Changes @@ -7,6 +7,10 @@ - Documentation corrections for Util methods around localized PSGI $env. - Improvements to auto detection of terminal width. - Updating deprecation list to include Class::Load and ensure_class_loaded + - Added a few docs around middleware and corrected the order that middleware + is loaded when registering it via ->setup_middleware instead of via + configuration. + - Added a test case to make sure default middleware order is correct. s 5.90062 - 2014-04-14 - HTTP::Exception objects were not properly bubbled up to middleware since diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index 10966eb..aa7b2e6 100755 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -3107,6 +3107,10 @@ which sounds odd but is likely how you expect it to work if you have prior experience with L or if you previously used the plugin L (which is now considered deprecated) +So basically your middleware handles an incoming request from the first +registered middleware, down and handles the response from the last middleware +up. + =cut sub registered_middlewares { @@ -3128,7 +3132,7 @@ sub registered_middlewares { sub setup_middleware { my $class = shift; my @middleware_definitions = @_ ? - @_ : reverse(@{$class->config->{'psgi_middleware'}||[]}); + reverse(@_) : reverse(@{$class->config->{'psgi_middleware'}||[]}); my @middleware = (); while(my $next = shift(@middleware_definitions)) {