Skip to content

Commit

Permalink
Undo change in Mojo::UserAgent::Server.
Browse files Browse the repository at this point in the history
We can instead adapt the start() method of Mojo::Server::Daemon to
leave Mojo::UserAgent::Server in pristine state.
  • Loading branch information
Raphael Manfredi committed Apr 6, 2021
1 parent b12fef3 commit d50deba
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
1 change: 1 addition & 0 deletions lib/Mojo/Server/Daemon.pm
Expand Up @@ -54,6 +54,7 @@ sub start {
# Start listening
elsif (!@{$self->acceptors}) {
$self->app->server($self);
$self->app->worker_starting;
$self->_listen($_) for @{$self->listen};
}

Expand Down
7 changes: 1 addition & 6 deletions lib/Mojo/UserAgent/Server.pm
Expand Up @@ -12,16 +12,11 @@ sub app {

# Singleton application
state $singleton;
unless (ref $self) {
my $starting = ref $app && (!defined $singleton || $singleton ne $app);
$app->worker_starting if $starting;
return $singleton = $app ? $app : $singleton;
}
return $singleton = $app ? $app : $singleton unless ref $self;

# Default to singleton application
return $self->{app} || $singleton unless $app;
$self->{app} = $app;
$app->worker_starting;
return $self;
}

Expand Down
5 changes: 4 additions & 1 deletion t/mojo/daemon.t
Expand Up @@ -171,7 +171,10 @@ $app->routes->any(
}
);

$app->routes->any('/*whatever' => {text => $whatever});
$app->routes->any('/*whatever' => sub {
my ($c) = shift;
$c->render(text => $whatever);
});

subtest 'Normal request' => sub {
my $tx = $ua->get('/normal/');
Expand Down

0 comments on commit d50deba

Please sign in to comment.