Commit | Line | Data |
178f8470 |
1 | package Catalyst::Action::Serialize::Callback; |
2 | |
3 | use Moose; |
4 | use namespace::autoclean; |
5 | |
6 | extends 'Catalyst::Action'; |
178f8470 |
7 | |
178f8470 |
8 | sub execute { |
9 | my $self = shift; |
10 | my ( $controller, $c, $callbacks ) = @_; |
11 | |
12 | my $stash_key = ( |
13 | $controller->{'serialize'} ? |
14 | $controller->{'serialize'}->{'stash_key'} : |
15 | $controller->{'stash_key'} |
16 | ) || 'rest'; |
17 | my $output = $callbacks->{serialize}->( $c->stash->{$stash_key}, $controller, $c ); |
18 | $c->response->output( $output ); |
19 | return 1; |
20 | } |
21 | |
22 | __PACKAGE__->meta->make_immutable; |
23 | |
24 | 1; |