package Catalyst::View::Base::JSON;
use base 'Catalyst::View';
use HTTP::Status;
use Scalar::Util;
our $VERSION = 0.003;
our $CLASS_INFO = 'Catalyst::View::Base::JSON::_ClassInfo';
my $inject_http
_headers($_->headers)
if $self->can('amend_headers');
unless($_->has_body) {
my $json = $self->render($possible_override_data);
if(my $param = $self->$class_info->callback_param
allback parameter $cb";
$json = "$cb($json)";
}
$_->body($json);
}
}
}
sub render {
my ($self, $possible_override_data) = @_;
my $to_json_encode = $possible_override_dat
st::View::Base::JSON::_ClassInfo;
use Moo;
use Scalar::Util;
use Catalyst::Utils;
our $DEFAULT_JSON_CLASS = 'JSON::MaybeXS';
our $DEFAULT_CONTENT_TYPE = 'application/json';
our %JSON_INIT_ARGS = (
);
has json => (
is=>'ro',
required=>1,
init_arg=>undef,
lazy=>1,
default=>sub {
my $self = shift;
eval "use ${\$self->json_class}; 1" ||
die "Can't use ${\$self->json_class},
$@";
return $self->json_class->new(
$self->json_init_args);
});
has content_type => (
is=>'ro',
required=>1,
default=>$DEFAULT_CONTENT_TYPE);
has returns_status => (
is=>'ro',