Async-Microservice

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

    If $payload is a reference, it is serialized as JSON. When JSONP is
    enabled and a valid callback parameter is present, the response is
    emitted as application/javascript instead of application/json.

 redirect($location_path)

    Send redirect.

 static_ft($file_name, $content_cb)

    Send static file, can be updated/modified using optional callback.

 get_pending_req

    Returns number of currently pending async requests.


----------------------------------------------------------------------------
NAME

    Async::Microservice::Time - example time async microservice

lib/Async/MicroserviceReq.pm  view on Meta::CPAN

If C<$payload> is a reference, it is serialized as JSON. When JSONP is
enabled and a valid callback parameter is present, the response is emitted as
C<application/javascript> instead of C<application/json>.

=head2 redirect($location_path)

Send redirect.

=head2 static_ft($file_name, $content_cb)

Send static file, can be updated/modified using optional callback.

=head2 get_pending_req

Returns number of currently pending async requests.

=cut

t/01_Async-Microservice.t  view on Meta::CPAN

    $mech->get( $service_url . 'static/non-existing-file' );
    is( $mech->status, 404, 'non-existing file returns 404' );
};

subtest 'OpenAPI' => sub {
    note($service_url);
    $mech->get_ok($service_url);
    $mech->content_contains( '<div id="swagger-ui">',
        'OpenAPI documentation in /' ) or return;
    $mech->content_contains( '<title>OpenAPI - asmi-helloworld</title>',
        'OpenAPI documentation updated' );
    $mech->get_ok( $service_url . 'edit' );
    $mech->content_contains( '<div id="swagger-editor">',
        'OpenAPI editor in /edit' );
};

subtest 'redirect' => sub {
    my $root_url = URI->new($service_url)->clone;
    $root_url->path('/');
    $mech->get( $root_url, host => 'hackme.example' );
    is( $mech->base, $service_url, 'redirected to root path' );



( run in 0.413 second using v1.01-cache-2.11-cpan-39bf76dae61 )