line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::JSONP; |
2
|
2
|
|
|
2
|
|
1894
|
use Mojo::Base 'Mojolicious::Plugin'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
17
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
sub register { |
7
|
2
|
|
|
2
|
1
|
95
|
my ($self, $app, $conf) = @_; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
$app->helper( |
10
|
|
|
|
|
|
|
render_jsonp => sub { |
11
|
4
|
|
|
4
|
|
141250
|
my ($self, $callback, $ref) = @_; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# $callback is optional |
14
|
4
|
100
|
|
|
|
47
|
$ref = $callback, undef $callback if !defined $ref; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# use default from plugin conf if callback not specified |
17
|
|
|
|
|
|
|
#$callback //= $self->param($conf->{callback}); |
18
|
4
|
100
|
|
|
|
48
|
$callback = $self->param($conf->{callback}) if !$callback; |
19
|
|
|
|
|
|
|
|
20
|
4
|
100
|
|
|
|
1895
|
return $callback |
21
|
|
|
|
|
|
|
? $self->render(text => $callback . '(' |
22
|
|
|
|
|
|
|
. $self->render(json => $ref, partial => 1) . ')') |
23
|
|
|
|
|
|
|
: $self->render(json => $ref); |
24
|
|
|
|
|
|
|
} |
25
|
2
|
|
|
|
|
33
|
); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
1; |
29
|
|
|
|
|
|
|
__END__ |