Commit | Line | Data |
0ba73721 |
1 | package Test::Catalyst::Action::REST::Controller::REST; |
2 | |
930013e6 |
3 | use Moose; |
4 | use namespace::autoclean; |
0ba73721 |
5 | |
930013e6 |
6 | BEGIN { extends 'Catalyst::Controller::REST' } |
0ba73721 |
7 | |
8 | sub test : Local { |
9fb09119 |
9 | my ( $self, $c ) = @_; |
10 | $self->status_ok( $c, |
11 | entity => { test => 'worked', data => $c->req->data } ); |
12 | } |
13 | |
14 | sub test_status_created : Local { |
15 | my ( $self, $c ) = @_; |
16 | $self->status_created( |
17 | $c, |
18 | location => '/rest', |
19 | entity => { status => 'created' } |
20 | ); |
21 | } |
22 | |
bdff70a9 |
23 | sub test_status_multiple_choices : Local { |
24 | my ( $self, $c ) = @_; |
25 | $self->status_multiple_choices( |
26 | $c, |
27 | location => '/rest/choice1', |
28 | entity => { choices => [qw(/rest/choice1 /rest/choice2)] } |
29 | ); |
30 | } |
31 | |
e52456a4 |
32 | sub test_status_found : Local { |
33 | my ( $self, $c ) = @_; |
34 | $self->status_found( |
35 | $c, |
36 | location => '/rest', |
37 | entity => { status => 'found' }, |
38 | ); |
39 | } |
40 | |
9fb09119 |
41 | sub test_status_accepted : Local { |
42 | my ( $self, $c ) = @_; |
259c53c7 |
43 | $self->status_accepted( |
44 | $c, |
45 | location => '/rest', |
46 | entity => { status => "queued", } |
47 | ); |
9fb09119 |
48 | } |
49 | |
50 | sub test_status_no_content : Local { |
51 | my ( $self, $c ) = @_; |
52 | $self->status_no_content($c); |
53 | } |
54 | |
55 | sub test_status_bad_request : Local { |
56 | my ( $self, $c ) = @_; |
57 | $self->status_bad_request( $c, |
58 | message => "Cannot do what you have asked!", ); |
59 | } |
60 | |
550807bc |
61 | sub test_status_forbidden : Local { |
62 | my ( $self, $c ) = @_; |
63 | $self->status_forbidden ( $c, |
64 | message => "access denied", ); |
65 | } |
66 | |
9fb09119 |
67 | sub test_status_not_found : Local { |
68 | my ( $self, $c ) = @_; |
69 | $self->status_not_found( $c, |
70 | message => "Cannot find what you were looking for!", ); |
71 | } |
72 | |
73 | sub test_status_gone : Local { |
74 | my ( $self, $c ) = @_; |
75 | $self->status_gone( $c, |
76 | message => "Document have been deleted by foo", ); |
0ba73721 |
77 | } |
78 | |
3c8c4876 |
79 | sub opts : Local ActionClass('REST') {} |
80 | |
81 | sub opts_GET { |
82 | my ( $self, $c ) = @_; |
83 | $self->status_ok( $c, entity => { opts => 'worked' } ); |
84 | } |
85 | |
0ba73721 |
86 | 1; |