From: Matt S Trout Date: Mon, 17 Jan 2011 10:40:35 +0000 (+0000) Subject: Make Web::Dispatch return [$cv] as $cv to allow subref responses X-Git-Tag: release_0.006~8 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FWeb-Simple.git;a=commitdiff_plain;h=d9ae38d990f923f213576fdc880e246842fdd6c2 Make Web::Dispatch return [$cv] as $cv to allow subref responses --- diff --git a/Changes b/Changes index f5d3098..f3c6aac 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,7 @@ Change log for Web::Simple + - Make Web::Dispatch return [\$cv] as \$cv to allow subref responses + 0.005 - Tue Jan 11 2011 22:09 UTC - Redocument to cover changes - Factor dispatcher code out into Web::Dispatch diff --git a/lib/Web/Dispatch.pm b/lib/Web/Dispatch.pm index 1b2dda0..d9e76ca 100644 --- a/lib/Web/Dispatch.pm +++ b/lib/Web/Dispatch.pm @@ -40,6 +40,9 @@ sub _dispatch { my @result = $self->_to_try($try, \@match)->($env, @match); next unless @result and defined($result[0]); if (ref($result[0]) eq 'ARRAY') { + if (@{$result[0]} == 1 and ref($result[0][0]) eq 'CODE') { + return $result[0][0]; + } return $result[0]; } elsif (blessed($result[0]) && $result[0]->isa('Plack::Middleware')) { die "Multiple results but first one is a middleware ($result[0])"