line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catalyst::Action::Serialize::JSONP; |
2
|
|
|
|
|
|
|
$Catalyst::Action::Serialize::JSONP::VERSION = '1.19'; |
3
|
1
|
|
|
1
|
|
4
|
use Moose; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
8
|
|
4
|
1
|
|
|
1
|
|
5360
|
use namespace::autoclean; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
9
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
extends 'Catalyst::Action::Serialize::JSON'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
after 'execute' => sub { |
9
|
|
|
|
|
|
|
my $self = shift; |
10
|
|
|
|
|
|
|
my ($controller, $c) = @_; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
my $callback_key = ( |
13
|
|
|
|
|
|
|
$controller->{'serialize'} ? |
14
|
|
|
|
|
|
|
$controller->{'serialize'}->{'callback_key'} : |
15
|
|
|
|
|
|
|
$controller->{'callback_key'} |
16
|
|
|
|
|
|
|
) || 'callback'; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my $callback_value = $c->req->param($callback_key); |
19
|
|
|
|
|
|
|
if ($callback_value) { |
20
|
|
|
|
|
|
|
if ($callback_value =~ /^[.\w]+$/) { |
21
|
|
|
|
|
|
|
$c->res->content_type('text/javascript'); |
22
|
|
|
|
|
|
|
$c->res->output($callback_value.'('.$c->res->output().');'); |
23
|
|
|
|
|
|
|
} else { |
24
|
|
|
|
|
|
|
warn 'Callback: '.$callback_value.' will not generate valid Javascript. Falling back to JSON output'; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
}; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
1; |