Commit 02e624fb authored by Michael Pyne's avatar Michael Pyne

mojo: Minor cleanup on GET modulesFromCommand route handler.

Super minor stuff: Use a 'guard clause' and put the multi-line
conditional opening brace on its own line.
parent 56063cfb
Pipeline #7590 passed with stage
in 1 minute and 27 seconds
......@@ -255,24 +255,26 @@ sub _generateRoutes {
my $work = $c->app->ksb->workLoad() // {};
my $info = $work->{dependencyInfo};
if (defined($info)
&& !ksb::DependencyResolver::hasErrors($info)
&& exists $info->{graph}) {
my $graph = $info->{graph};
my $modules = $work->{modulesFromCommand};
my @dtos = ksb::dto::ModuleInfo::selectedModulesToDtos(
$graph,
$modules
);
#
# Trap for the unwary: make sure to return a reference.
# Without this Mojolicious won't encode the array properly
#
$c->render(json => \@dtos);
}
else {
if (!defined($info)
|| ksb::DependencyResolver::hasErrors($info)
|| !exists $info->{graph})
{
$c->reply->not_found;
return;
}
my $graph = $info->{graph};
my $modules = $work->{modulesFromCommand};
my @dtos = ksb::dto::ModuleInfo::selectedModulesToDtos(
$graph,
$modules
);
#
# Trap for the unwary: make sure to return a reference.
# Without this Mojolicious won't encode the array properly
#
$c->render(json => \@dtos);
});
$r->post('/build' => sub {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment