File: HTTPMethods.pm

package info (click to toggle)
libcatalyst-perl 5.90132-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,016 kB
  • sloc: perl: 11,061; makefile: 7
file content (97 lines) | stat: -rw-r--r-- 2,238 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
package TestApp::Controller::HTTPMethods;

use Moose;
use MooseX::MethodAttributes;

extends 'Catalyst::Controller';

sub default : Path Args {
    my ($self, $ctx) = @_;
    $ctx->response->body('default');
}

sub get : Path('foo') Method('GET') {
    my ($self, $ctx) = @_;
    $ctx->response->body('get');
}

sub post : Path('foo') Method('POST') {
    my ($self, $ctx) = @_;
    $ctx->response->body('post');
}

sub get_or_post : Path('bar') Method('GET') Method('POST') {
    my ($self, $ctx) = @_;
    $ctx->response->body('get or post');
}

sub any_method : Path('baz') {
    my ($self, $ctx) = @_;
    $ctx->response->body('any');
}

sub typo_option : Path('opt_typo') OPTION {
    my ($self, $ctx) = @_;
    $ctx->response->body('typo');
}

sub real_options : Path('opt') OPTIONS {
    my ($self, $ctx) = @_;
    $ctx->response->body('options');
}

sub base :Chained('/') PathPrefix CaptureArgs(0) { }

sub chained_get :Chained('base') Args(0) GET {
    pop->res->body('chained_get');
}

sub chained_post :Chained('base') Args(0) POST {
    pop->res->body('chained_post');
}

sub chained_put :Chained('base') Args(0) PUT {
    pop->res->body('chained_put');
}

sub chained_delete :Chained('base') Args(0) DELETE {
    pop->res->body('chained_delete');
}

sub get_or_put :Chained('base') PathPart('get_put_post_delete') CaptureArgs(0) GET PUT { }

sub get2 :Chained('get_or_put') PathPart('') Args(0) GET {
    pop->res->body('get2');
}

sub put2 :Chained('get_or_put') PathPart('') Args(0) PUT {
    pop->res->body('put2');
}

sub post_or_delete :Chained('base') PathPart('get_put_post_delete') CaptureArgs(0) POST DELETE { }

sub post2 :Chained('post_or_delete') PathPart('') Args(0) POST {
    pop->res->body('post2');
}

sub delete2 :Chained('post_or_delete') PathPart('') Args(0) DELETE {
    pop->res->body('delete2');
}

sub check_default :Chained('base') CaptureArgs(0) { }

sub chain_default :Chained('check_default') PathPart('') Args(0) {
    pop->res->body('chain_default');
}

sub default_get :Chained('check_default') PathPart('') Args(0) GET {
    pop->res->body('get3');
}

sub default_post :Chained('check_default') PathPart('') Args(0) POST {
    pop->res->body('post3');
}



__PACKAGE__->meta->make_immutable;