Commit | Line | Data |
838f49dc |
1 | package Test::Serialize::Controller::JSON; |
2 | |
3 | use namespace::autoclean; |
4 | use Moose; |
5 | |
6 | BEGIN { extends qw/Catalyst::Controller::REST/ }; |
7 | |
8 | __PACKAGE__->config( |
9 | 'stash_key' => 'rest', |
10 | 'json_options' => { |
11 | relaxed => 1, |
12 | }, |
13 | 'map' => { |
14 | 'text/x-json' => 'JSON', |
15 | }, |
16 | ); |
17 | |
18 | sub monkey_json_put : Path("/monkey_json_put") : ActionClass('Deserialize') { |
19 | my ( $self, $c ) = @_; |
20 | if ( ref($c->req->data) eq "HASH" ) { |
21 | my $out = ($c->req->data->{'sushi'}||'') . ($c->req->data->{'chicken'}||''); |
22 | utf8::encode($out); |
23 | $c->res->output( $out ); |
24 | } else { |
25 | $c->res->output(1); |
26 | } |
27 | } |
28 | |
29 | 1; |