Amon2-Lite

 view release on metacpan or  search on metacpan

lib/Amon2/Lite.pm  view on Meta::CPAN


    *{"$caller\::post"} = sub {
        $router->connect($_[0], {code => $_[1], method => ['POST']}, {method => ['POST']});
    };

    *{"${base_class}\::dispatch"} = sub {
        my ($c) = @_;
        if (my $p = $router->match($c->request->env)) {
            return $p->{code}->( $c, $p );
        } else {
            if ($router->method_not_allowed) {
                my $content = '405 Method Not Allowed';
                return $c->create_response(
                    405,
                    [
                        'Content-Type'   => 'text/plain; charset=utf-8',
                        'Content-Length' => length($content),
                    ],
                    [$content]
                );
            } else {

t/400_lite/09_get_post.t  view on Meta::CPAN

    is($res->content, 'post');
};
subtest 'GET /get_only' => sub {
    my $res = res_from_psgi($app->(req_to_psgi(GET 'http://localhost/get_only')));
    is($res->code, 200);
};
subtest 'POST /get_only' => sub {
    my $res = res_from_psgi($app->(req_to_psgi(POST 'http://localhost/get_only')));
    is($res->code, 405);
};
subtest 'GET /not_found' => sub {
    my $res = res_from_psgi($app->(req_to_psgi(POST 'http://localhost/not_found')));
    is($res->code, 404);
};

done_testing;



( run in 0.623 second using v1.01-cache-2.11-cpan-cc502c75498 )