Skip to content

Commit

Permalink
reversed order of how we apply middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
jjn1056 committed Apr 7, 2012
1 parent 0d80a9c commit 3303f71
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
4 changes: 4 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
Revision history for Catalyst-Plugin-EnableMiddleware

0.006 06 April 2012
- reverse order that middleware is applied so that it
act as Plack::Builder (could be breaking change, FYI)

0.005 06 April 2012
- fixed missing changelog
- adding debug output of loaded middleware
Expand Down
2 changes: 1 addition & 1 deletion dist.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ author = John Napiorkowski <jjnapiork@cpan.org>
license = Perl_5
copyright_holder = John Napiorkowski
copyright_year = 2012
version = 0.005
version = 0.006

[@Basic]
[Prereqs]
Expand Down
8 changes: 6 additions & 2 deletions lib/Catalyst/Plugin/EnableMiddleware.pm
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use Scalar::Util;
use Catalyst::Utils;
use Text::SimpleTable;

our $VERSION = '0.005';
our $VERSION = '0.006';

around 'psgi_app', sub {
my ($orig, $self, @args) = @_;
Expand All @@ -19,7 +19,7 @@ around 'psgi_app', sub {
my $column_width = Catalyst::Utils::term_width() - 6;
my $t = Text::SimpleTable->new($column_width);

my @mw = @{$self->config->{'Plugin::EnableMiddleware'}||[]};
my @mw = reverse @{$self->config->{'Plugin::EnableMiddleware'}||[]};
while(my $next = shift(@mw)) {
if(Scalar::Util::blessed $next && $next->can('wrap')) {
$t->row(ref $next);
Expand All @@ -28,6 +28,10 @@ around 'psgi_app', sub {
if($type eq 'CODE') {
$t->row('CodeRef');
$psgi_app = $next->($psgi_app);
} elsif($type eq 'HASH') {
my $module = Plack::Util::load_class(shift @mw, 'Plack::Middleware');
$t->row($module);
$psgi_app = $module->wrap($psgi_app, %$next);
}
} else {
my $normalized_next = Plack::Util::load_class($next, 'Plack::Middleware');
Expand Down

0 comments on commit 3303f71

Please sign in to comment.