Skip to content

Commit

Permalink
Merge branch 'feature/set-apphandler'
Browse files Browse the repository at this point in the history
  • Loading branch information
xsawyerx committed May 19, 2014
2 parents fbe0947 + 3805dcf commit e876e8e
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{{$NEXT}}

[ BUG FIXES ]
* GH #447: Setting the apphandler now triggers the Dancer Runner
configuration change, which works. (Sawyer X)


[ DOCUMENTATION ]
* Fix doc for params(). Ported from Dancer#1025 (Stefan Hornburg)

Expand Down
5 changes: 5 additions & 0 deletions lib/Dancer2/Core/Role/ConfigReader.pm
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ has global_triggers => (
require Carp;
$Carp::Verbose = $traces ? 1 : 0;
},

apphandler => sub {
my ( $self, $handler ) = @_;
Dancer2->runner->config->{'apphandler'} = $handler;
},
} },
);

Expand Down
34 changes: 34 additions & 0 deletions t/lwp-protocol-psgi.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/perl
use strict;
use warnings;
use Test::More tests => 5;
use LWP::UserAgent;

eval "use LWP::Protocol::PSGI";
plan skip_all => "LWP::Protocol::PSGI is needed for this test" if $@;

my $psgi_app = do {
use Dancer2;

set apphandler => 'PSGI';

get '/search' => sub {
my $q = param('q');
is( $q, 'foo', 'Correct parameter to Google' );
return 'bar';
};

dance;
};

# Register the $psgi_app to handle all LWP requests
LWP::Protocol::PSGI->register($psgi_app);
my $ua = LWP::UserAgent->new;
isa_ok( $ua, 'LWP::UserAgent' );

my $res = $ua->get("http://www.google.com/search?q=foo");
isa_ok( $res, 'HTTP::Response' );

ok( $res->is_success, 'Request is successful' );
is( $res->content, 'bar', 'Correct response content' );

0 comments on commit e876e8e

Please sign in to comment.