X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FWeb%2FDispatch.pm;fp=lib%2FWeb%2FDispatch.pm;h=1b2dda0ba85fbaca8f90da4983e75001d2c30fc6;hb=5ba2eb683d1a5e8ee76bfb1c7825c9826571be40;hp=581cc04b8f61d4dcf45569e62c61e2e762ab89de;hpb=69aaa28a5f4d0ed129aae1c4f8a1bf98684a73df;p=catagits%2FWeb-Simple.git diff --git a/lib/Web/Dispatch.pm b/lib/Web/Dispatch.pm index 581cc04..1b2dda0 100644 --- a/lib/Web/Dispatch.pm +++ b/lib/Web/Dispatch.pm @@ -41,10 +41,12 @@ sub _dispatch { next unless @result and defined($result[0]); if (ref($result[0]) eq 'ARRAY') { return $result[0]; - } elsif (blessed($result[0]) && $result[0]->can('wrap')) { - return $result[0]->wrap(sub { - $self->_dispatch($_[0], @match) - })->($env); + } elsif (blessed($result[0]) && $result[0]->isa('Plack::Middleware')) { + die "Multiple results but first one is a middleware ($result[0])" + if @result > 1; + my $mw = $result[0]; + $mw->app(sub { $self->_dispatch($_[0], @match) }); + return $mw->to_app->($env); } elsif (blessed($result[0]) && !$result[0]->can('to_app')) { return $result[0]; } else {