Amon2-Lite

 view release on metacpan or  search on metacpan

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

125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
*{"$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

35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
    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.293 second using v1.01-cache-2.11-cpan-bb97c1e446a )