1 package Catalyst::ActionRole::SerializeFormat;
3 use Catalyst::ControllerRole::SerializeConfig;
4 use Moose::Util qw(does_role);
5 use namespace::clean -except => 'meta';
8 around execute => sub {
10 my ($self, $controller, $c, $arg) = @_;
12 # XXX is ignoring the return value here correct? the original serialize
13 # actions never even called their body.
14 $self->$next($controller, $c, $arg)
17 Catalyst::ControllerRole::SerializeConfig->meta->apply($controller)
18 unless does_role($controller, 'Catalyst::ControllerRole::SerializeConfig');
20 my $stash_key = $controller->serialize_config->{stash_key} || 'rest';
24 $output = $self->serialize(
25 $c->stash->{$stash_key},
31 # horrible, but the best I can do given the existing magic return value
33 return $output if $output eq '0';
34 $c->response->body($output) unless $c->response->body;