Tests which I believe show that JSON encoding is handled correctly. I.E. You pass...
[catagits/Catalyst-Action-REST.git] / t / lib / Test / Serialize / Controller / REST.pm
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         'application/json'   => 'JSON',
16         'text/x-json'        => 'JSON',
17         'text/x-data-dumper' => [ 'Data::Serializer', 'Data::Dumper' ],
18         'text/x-data-denter' => [ 'Data::Serializer', 'Data::Denter' ],
19         'text/x-data-taxi'   => [ 'Data::Serializer', 'Data::Taxi' ],
20         'application/x-storable' => [ 'Data::Serializer', 'Storable' ],
21         'application/x-freezethaw' =>
22             [ 'Data::Serializer', 'FreezeThaw' ],
23         'text/x-config-general' =>
24             [ 'Data::Serializer', 'Config::General' ],
25         'text/x-php-serialization' =>
26              [ 'Data::Serializer', 'PHP::Serialization' ],
27         'text/view'   => [ 'View', 'Simple' ],
28         'text/broken' => 'Broken',
29     },
30 );
31
32 sub monkey_put : Local : ActionClass('Deserialize') {
33     my ( $self, $c ) = @_;
34     if ( ref($c->req->data) eq "HASH" ) {
35         my $out = $c->req->data->{'sushi'} . $c->req->data->{'chicken'}||'';
36         utf8::encode($out);
37         $c->res->output( $out );
38     } else {
39         $c->res->output(1);
40     }
41 }
42
43 sub monkey_get : Local : ActionClass('Serialize') {
44     my ( $self, $c ) = @_;
45     $c->stash->{'rest'} = { monkey => 'likes chicken!', };
46 }
47
48 1;