kage Mojolicious::Plugin::JSONP;
use Mojo::Base 'Mojolicious::Plugin';
our $VERSION = '0.04';
sub register {
my ($self, $app, $conf) = @_;
$app->helper(
render_jsonp => sub {
my ($sel
ethod(json => $ref, partial => 1) . ')')
: $self->render(json => $ref);
}
);
}
1;
__END__
=head1 NAME
Mojolicious::Plugin::JSONP - Render JSONP with transparent fallback to JSON
=hea
d1 SYNOPSIS
plugin JSONP => callback => 'callback_function';
get '/' => sub {
shift->render_jsonp({one => 'two'});
};
# GET request:
# ?callback_function=my_function
# Response: