xing
Directory;
use 5.008;
use strict;
use warnings 'all';
use parent 'CGI::Application';
use JSON 2.00; # The API was changed
use Try::Tiny;
use WWW::USF::Directory;
sub setup {
my ($self) = @_
ults and response
my (@results, $response);
# Set the header to specity JSON
$self->header_add(-type => 'application/json');
try {
# Search the directory
@results = $self->{directory}->searc
il } } @results;
# Return the JSON-encoded results to print
$response = JSON->new->encode(\@results);
}
catch {
# Return an empty JSON list
$response = JSON->new->encode([]);
};
# Return
ckage Directory;
use 5.008;
use strict;
use warnings 'all';
use parent 'CGI::Application';
use JSON 2.00; # The API was changed
use Try::Tiny;
use WWW::USF::Directory;
sub setup {
my ($self) = @_
ults and response
my (@results, $response);
# Set the header to specity JSON
$self->header_add(-type => 'application/json');
try {
# Search the directory
@results = $self->{directory}->searc
he JSON-encoded results to print
$response = JSON->new->encode({
results => \@results,
});
}
catch {
# Get the error
my $error = $_;
# Return a JSON with the error
$response = JSON->