1 package Test::Catalyst::Action::REST::Controller::REST;
4 use namespace::autoclean;
6 BEGIN { extends 'Catalyst::Controller::REST' }
10 'text/html' => 'YAML::HTML',
11 'text/x-yaml' => 'YAML',
15 my ( $self, $c ) = @_;
17 entity => { test => 'worked', data => $c->req->data } );
20 sub test_status_created : Local {
21 my ( $self, $c ) = @_;
22 $self->status_created(
25 entity => { status => 'created' }
29 sub test_status_multiple_choices : Local {
30 my ( $self, $c ) = @_;
31 $self->status_multiple_choices(
33 location => '/rest/choice1',
34 entity => { choices => [qw(/rest/choice1 /rest/choice2)] }
38 sub test_status_found : Local {
39 my ( $self, $c ) = @_;
43 entity => { status => 'found' },
47 sub test_status_accepted : Local {
48 my ( $self, $c ) = @_;
49 $self->status_accepted(
52 entity => { status => "queued", }
56 sub test_status_no_content : Local {
57 my ( $self, $c ) = @_;
58 $self->status_no_content($c);
61 sub test_status_bad_request : Local {
62 my ( $self, $c ) = @_;
63 $self->status_bad_request( $c,
64 message => "Cannot do what you have asked!", );
67 sub test_status_forbidden : Local {
68 my ( $self, $c ) = @_;
69 $self->status_forbidden ( $c,
70 message => "access denied", );
73 sub test_status_not_found : Local {
74 my ( $self, $c ) = @_;
75 $self->status_not_found( $c,
76 message => "Cannot find what you were looking for!", );
79 sub test_status_gone : Local {
80 my ( $self, $c ) = @_;
81 $self->status_gone( $c,
82 message => "Document have been deleted by foo", );
85 sub test_status_see_other : Local {
86 my ( $self, $c ) = @_;
87 $self->status_see_other(
90 entity => { somethin => 'happenin' }
94 sub opts : Local ActionClass('REST') {}
97 my ( $self, $c ) = @_;
98 $self->status_ok( $c, entity => { opts => 'worked' } );
101 sub opts_not_implemented {
102 my ( $self, $c ) = @_;
103 $c->res->status(405);
104 $c->res->header('Allow' => [qw(GET HEAD)]);
105 $c->res->body('Not implemented');