1 package TestApp::Controller::HTTPMethods;
4 use MooseX::MethodAttributes;
6 extends 'Catalyst::Controller';
8 sub default : Path Args {
10 $ctx->response->body('default');
13 sub get : Path('foo') Method('GET') {
14 my ($self, $ctx) = @_;
15 $ctx->response->body('get');
18 sub post : Path('foo') Method('POST') {
19 my ($self, $ctx) = @_;
20 $ctx->response->body('post');
23 sub get_or_post : Path('bar') Method('GET') Method('POST') {
24 my ($self, $ctx) = @_;
25 $ctx->response->body('get or post');
28 sub any_method : Path('baz') {
29 my ($self, $ctx) = @_;
30 $ctx->response->body('any');
33 sub typo_option : Path('opt_typo') OPTION {
34 my ($self, $ctx) = @_;
35 $ctx->response->body('typo');
38 sub real_options : Path('opt') OPTIONS {
39 my ($self, $ctx) = @_;
40 $ctx->response->body('options');
43 sub base :Chained('/') PathPrefix CaptureArgs(0) { }
45 sub chained_get :Chained('base') Args(0) GET {
46 pop->res->body('chained_get');
49 sub chained_post :Chained('base') Args(0) POST {
50 pop->res->body('chained_post');
53 sub chained_put :Chained('base') Args(0) PUT {
54 pop->res->body('chained_put');
57 sub chained_delete :Chained('base') Args(0) DELETE {
58 pop->res->body('chained_delete');
61 sub get_or_put :Chained('base') PathPart('get_put_post_delete') CaptureArgs(0) GET PUT { }
63 sub get2 :Chained('get_or_put') PathPart('') Args(0) GET {
64 pop->res->body('get2');
67 sub put2 :Chained('get_or_put') PathPart('') Args(0) PUT {
68 pop->res->body('put2');
71 sub post_or_delete :Chained('base') PathPart('get_put_post_delete') CaptureArgs(0) POST DELETE { }
73 sub post2 :Chained('post_or_delete') PathPart('') Args(0) POST {
74 pop->res->body('post2');
77 sub delete2 :Chained('post_or_delete') PathPart('') Args(0) DELETE {
78 pop->res->body('delete2');
81 sub check_default :Chained('base') CaptureArgs(0) { }
83 sub chain_default :Chained('check_default') PathPart('') Args(0) {
84 pop->res->body('chain_default');
87 sub default_get :Chained('check_default') PathPart('') Args(0) GET {
88 pop->res->body('get3');
91 sub default_post :Chained('check_default') PathPart('') Args(0) POST {
92 pop->res->body('post3');
97 __PACKAGE__->meta->make_immutable;