[Catalyst] JSONP support Catalyst::Controller::DBIC::API
Rajesh Kumar Mallah
mallah at redgrape.tech
Thu Mar 9 02:15:17 GMT 2017
Hi ,
How to get JSON response body wrapped in a callback function
call (a.k.a JSONP) when using Catalyst::Controller::DBIC::API::REST
I use Catalyst::Controller::DBIC::API and 'end' function
in ControllerBase is like below:
sub end : Private {
my ( $self, $c ) = @_;
##
# code for manipulating stash here
##
$c->forward('serialize');
}
=============================================
In Catalyst/Controller/DBIC/API.pm
# from Catalyst::Action::Serialize
sub serialize : ActionClass('Serialize') { }
=============================================
My other JSON responses which are rendered via MyApp::View::JSON
can be modified as JSONP compatible as i have below in my App config
__PACKAGE__->config({
'View::JSON' => {
allow_callback => 1, # defaults to 0
},
});
===============================================
The problem is only with automatically generated rest endpoints
from Catalyst::Controller::DBIC::API.
Thanks in anticipation.
Regds
mallah.
More information about the Catalyst
mailing list