Amon2-Plugin-Web-CpanelJSON

 view release on metacpan or  search on metacpan

t/01_render_json.t  view on Meta::CPAN

use strict;
use warnings;
use Test::More;
use Plack::Test;
use HTTP::Request::Common;
use Cpanel::JSON::XS::Type;

{
    package MyApp::Web;
    use parent qw(Amon2 Amon2::Web);
    __PACKAGE__->load_plugins('Web::CpanelJSON');
    sub encoding { 'utf-8' }
}

my $app = MyApp::Web->to_app;

t/10-config/name.t  view on Meta::CPAN

use strict;
use warnings;
use Test::More;
use Plack::Test;
use HTTP::Request::Common;
use Cpanel::JSON::XS::Type;

{
    package MyApp::Web;
    use parent qw(Amon2 Amon2::Web);
    __PACKAGE__->load_plugins('Web::CpanelJSON', { name => 'my_json' });
    sub encoding { 'utf-8' }
}

{

t/99_synopsis.t  view on Meta::CPAN

        message => JSON_TYPE_STRING,
    };

    get '/' => sub {
        my $c = shift;
        return $c->render_json(+{ message => 'HELLO!' }, HelloWorld, HTTP_OK);
    };
}

use Plack::Test;
use HTTP::Request::Common;

my $app = MyApp->to_app();
test_psgi $app, sub {
    my $cb  = shift;
    my $res = $cb->(GET "/");

    is $res->code, 200;
    is $res->content, '{"message":"HELLO!"}';
};



( run in 0.941 second using v1.01-cache-2.11-cpan-de7293f3b23 )