1 package Test::Catalyst::Action::REST::Controller::Serialize;
4 use namespace::autoclean;
6 BEGIN { extends 'Catalyst::Controller' }
9 'default' => 'text/x-yaml',
10 'stash_key' => 'rest',
12 'text/x-yaml' => 'YAML',
13 'application/json' => 'JSON',
14 'text/x-data-dumper' => [ 'Data::Serializer', 'Data::Dumper' ],
15 'text/broken' => 'Broken',
19 sub test :Local :ActionClass('Serialize') {
20 my ( $self, $c ) = @_;
21 $c->stash->{'rest'} = {
26 sub test_second :Local :ActionClass('Serialize') {
27 my ( $self, $c ) = @_;
28 # 'serialize_content_type' is configured in the test config in t/conf
29 $c->stash->{'serialize_content_type'} = $c->req->params->{'serialize_content_type'};
30 $c->stash->{'rest'} = {
35 # For testing saying 'here is an explicitly empty body, do not serialize'
36 sub empty : Chained('/') PathPart('serialize') CaptureArgs(0) {
38 $c->stash( rest => { foo => 'bar' } );
42 sub empty_serialized :Chained('empty') Args(0) ActionClass('Serialize') {
46 sub empty_not_serialized_undef :Chained('empty') Args(0) ActionClass('Serialize') {
52 sub empty_not_serialized_blank :Chained('empty') Args(0) ActionClass('Serialize') {