Commit | Line | Data |
86fe5297 |
1 | package Test::Serialize::Controller::REST; |
2 | |
3 | use warnings; |
4 | use strict; |
5 | |
6 | use base qw/Catalyst::Controller::REST/; |
7 | |
8 | __PACKAGE__->config( |
9 | 'namespace' => '', |
10 | 'stash_key' => 'rest', |
11 | 'map' => { |
12 | 'text/html' => 'YAML::HTML', |
13 | 'text/xml' => 'XML::Simple', |
14 | 'text/x-yaml' => 'YAML', |
15 | 'text/x-json' => 'JSON', |
16 | 'text/x-data-dumper' => [ 'Data::Serializer', 'Data::Dumper' ], |
17 | 'text/x-data-denter' => [ 'Data::Serializer', 'Data::Denter' ], |
18 | 'text/x-data-taxi' => [ 'Data::Serializer', 'Data::Taxi' ], |
19 | 'application/x-storable' => [ 'Data::Serializer', 'Storable' ], |
20 | 'application/x-freezethaw' => |
21 | [ 'Data::Serializer', 'FreezeThaw' ], |
22 | 'text/x-config-general' => |
23 | [ 'Data::Serializer', 'Config::General' ], |
24 | 'text/x-php-serialization' => |
25 | [ 'Data::Serializer', 'PHP::Serialization' ], |
26 | 'text/view' => [ 'View', 'Simple' ], |
27 | 'text/broken' => 'Broken', |
28 | }, |
29 | ); |
30 | |
31 | sub monkey_put : Local : ActionClass('Deserialize') { |
32 | my ( $self, $c ) = @_; |
33 | if ( ref($c->req->data) eq "HASH" ) { |
34 | $c->res->output( $c->req->data->{'sushi'} ); |
35 | } else { |
36 | $c->res->output(1); |
37 | } |
38 | } |
39 | |
40 | sub monkey_get : Local : ActionClass('Serialize') { |
41 | my ( $self, $c ) = @_; |
42 | $c->stash->{'rest'} = { monkey => 'likes chicken!', }; |
43 | } |
44 | |
45 | 1; |
46 | |