test cases for the args0 issue
[catagits/Catalyst-Runtime.git] / t / lib / TestApp / Controller / HTTPMethods.pm
CommitLineData
760d121e 1package TestApp::Controller::HTTPMethods;
2
3use Moose;
4use MooseX::MethodAttributes;
5
6extends 'Catalyst::Controller';
7
8sub default : Path Args {
9 my ($self, $ctx) = @_;
10 $ctx->response->body('default');
11}
12
13sub get : Path('foo') Method('GET') {
14 my ($self, $ctx) = @_;
15 $ctx->response->body('get');
16}
17
18sub post : Path('foo') Method('POST') {
19 my ($self, $ctx) = @_;
20 $ctx->response->body('post');
21}
22
23sub get_or_post : Path('bar') Method('GET') Method('POST') {
24 my ($self, $ctx) = @_;
25 $ctx->response->body('get or post');
26}
27
28sub any_method : Path('baz') {
29 my ($self, $ctx) = @_;
30 $ctx->response->body('any');
31}
32
0c246eea 33sub typo_option : Path('opt_typo') OPTION {
34 my ($self, $ctx) = @_;
35 $ctx->response->body('typo');
36}
37
38sub real_options : Path('opt') OPTIONS {
39 my ($self, $ctx) = @_;
40 $ctx->response->body('options');
41}
42
760d121e 43sub base :Chained('/') PathPrefix CaptureArgs(0) { }
44
f3a49d84 45sub chained_get :Chained('base') Args(0) GET {
760d121e 46 pop->res->body('chained_get');
f3a49d84 47}
760d121e 48
f3a49d84 49sub chained_post :Chained('base') Args(0) POST {
760d121e 50 pop->res->body('chained_post');
f3a49d84 51}
760d121e 52
f3a49d84 53sub chained_put :Chained('base') Args(0) PUT {
760d121e 54 pop->res->body('chained_put');
f3a49d84 55}
760d121e 56
f3a49d84 57sub chained_delete :Chained('base') Args(0) DELETE {
760d121e 58 pop->res->body('chained_delete');
f3a49d84 59}
760d121e 60
f3a49d84 61sub get_or_put :Chained('base') PathPart('get_put_post_delete') CaptureArgs(0) GET PUT { }
760d121e 62
f3a49d84 63sub get2 :Chained('get_or_put') PathPart('') Args(0) GET {
64 pop->res->body('get2');
65}
760d121e 66
f3a49d84 67sub put2 :Chained('get_or_put') PathPart('') Args(0) PUT {
68 pop->res->body('put2');
69}
760d121e 70
f3a49d84 71sub post_or_delete :Chained('base') PathPart('get_put_post_delete') CaptureArgs(0) POST DELETE { }
760d121e 72
f3a49d84 73sub post2 :Chained('post_or_delete') PathPart('') Args(0) POST {
74 pop->res->body('post2');
75}
760d121e 76
f3a49d84 77sub delete2 :Chained('post_or_delete') PathPart('') Args(0) DELETE {
78 pop->res->body('delete2');
79}
760d121e 80
f3a49d84 81sub check_default :Chained('base') CaptureArgs(0) { }
760d121e 82
67b8d829 83sub chain_default :Chained('check_default') PathPart('') Args(0) {
84 pop->res->body('chain_default');
85}
86
f3a49d84 87sub default_get :Chained('check_default') PathPart('') Args(0) GET {
88 pop->res->body('get3');
89}
760d121e 90
f3a49d84 91sub default_post :Chained('check_default') PathPart('') Args(0) POST {
92 pop->res->body('post3');
93}
760d121e 94
67b8d829 95
760d121e 96
97__PACKAGE__->meta->make_immutable;