Skip to content

Commit

Permalink
Factor out actual application request dispatching in a wrappable method
Browse files Browse the repository at this point in the history
  • Loading branch information
phaylon committed Oct 30, 2014
1 parent ddb4870 commit c43a566
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions lib/Starman/Server.pm
Expand Up @@ -183,6 +183,19 @@ sub post_accept_hook {
};
}

sub dispatch_request {
my ($self, $env) = @_;

# Run PSGI apps
my $res = Plack::Util::run_app($self->{app}, $env);

if (ref $res eq 'CODE') {
$res->(sub { $self->_finalize_response($env, $_[0]) });
} else {
$self->_finalize_response($env, $res);
}
}

sub process_request {
my $self = shift;
my $conn = $self->{server}->{client};
Expand Down Expand Up @@ -277,14 +290,7 @@ sub process_request {

$self->_prepare_env($env);

# Run PSGI apps
my $res = Plack::Util::run_app($self->{app}, $env);

if (ref $res eq 'CODE') {
$res->(sub { $self->_finalize_response($env, $_[0]) });
} else {
$self->_finalize_response($env, $res);
}
$self->dispatch_request($env);

DEBUG && warn "[$$] Request done\n";

Expand Down

0 comments on commit c43a566

Please sign in to comment.