1use strict; 2use warnings; 3use Test::More; 4use Plack::Test; 5use HTTP::Request::Common; 6use Ref::Util qw<is_coderef>; 7 8subtest 'pass within routes' => sub { 9 { 10 11 package App; 12 use Dancer2; 13 14 get '/' => sub { 'hello' }; 15 get '/**' => sub { 16 response_header 'X-Pass' => 'pass'; 17 pass; 18 redirect '/'; # won't get executed as pass returns immediately. 19 }; 20 get '/pass' => sub { 21 return "the baton"; 22 }; 23 } 24 25 my $app = App->to_app; 26 ok( is_coderef($app), 'Got app' ); 27 28 test_psgi $app, sub { 29 my $cb = shift; 30 31 { 32 my $res = $cb->( GET '/pass' ); 33 is( $res->code, 200, '[/pass] Correct status' ); 34 is( $res->content, 'the baton', '[/pass] Correct content' ); 35 is( 36 $res->headers->header('X-Pass'), 37 'pass', 38 '[/pass] Correct X-Pass header', 39 ); 40 } 41 }; 42 43}; 44 45done_testing; 46