outline for PSGI middleware
John Napiorkowski [Thu, 18 Jul 2013 02:29:25 +0000 (22:29 -0400)]
Changes
lib/Catalyst.pm

diff --git a/Changes b/Changes
index 0a1b682..a7a9d5d 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,5 +1,8 @@
 # This file documents the revision history for Perl extension Catalyst.
 
+5.90XXX - TBA
+  - Declare PSGI compliant Middleware as part of your Catalyst Application
+
 5.90042 - 2013-06-14
   - Removed more places where an optional dependency shows up in the test
     suite. Hopefully really fixed the unicode regression introduced in 5.90040
index dc2e122..d0c2f27 100644 (file)
@@ -3044,6 +3044,27 @@ the plugin name does not begin with C<Catalyst::Plugin::>.
     }
 }
 
+sub setup_middleware { }
+
+our @registered_middlewares = ();
+
+## A normalized read only list of PSGI Middleware
+sub registered_middlewares { @registered_middlewares }
+
+## Normalize incoming middleware and hold it
+sub register_middleware {
+    my($self, $mw, @args) = @_;
+
+    if (ref $mw ne 'CODE') {
+        my $mw_class = Plack::Util::load_class($mw, 'Plack::Middleware');
+        $mw = sub { $mw_class->wrap($_[0], @args) };
+    }
+
+    push @registered_middlewares, $mw;
+}
+
+sub apply_registered_middleware { }
+
 =head2 $c->stack
 
 Returns an arrayref of the internal execution stack (actions that are