1 package Catalyst::ActionRole::Serialize;
3 use Catalyst::ControllerRole::SerializeConfig;
4 use Moose::Util qw(does_role);
5 use namespace::clean -except => 'meta';
8 around execute => sub {
9 # the original Serialize::* actions never executed their body, so this is
12 my ($self, $controller, $c, $arg) = @_;
13 Catalyst::ControllerRole::SerializeConfig->meta->apply($controller)
14 unless does_role($controller, 'Catalyst::ControllerRole::SerializeConfig');
16 my $stash_key = $controller->serialize_config->{stash_key} || 'rest';
20 $output = $self->serialize(
21 $c->stash->{$stash_key},
27 # horrible, but the best I can do given the existing magic return value
29 return $output if $output eq '0';
30 $c->response->body($output) unless $c->response->body;