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