;
BEGIN { extends 'Catalyst::Controller' };
with 'CatalystX::Controller::ExtJS::Direct';
use JSON::XS;
sub add : Chained('/') : Path : CaptureArgs(1) {
my($self,$c, $arg) = @_;
$c->stas
: DirectArgs(1) {
my ($self, $c) = @_;
$c->res->content_type('application/json');
$c->res->body(encode_json($c->req->data));
}
As you can see the C<add_to> action has the C<Direct> attri
which is always an arrayref and includes all arguments.
We set the content type to C<application/json> to make sure that the
body is not serialized twice. That is, if you would not set the content ty
},
accepted_content_types => ['application/json'],
content_types => ['application/json'],
content_type => 'application/json'
);
};
# split a request in multiple requests
$c->req->is_ext_upload )
{
unshift(@{$c->req->accepted_content_types}, 'application/json');
return 1;
}
else {
return $self->next::method( $controller, $c );
dAttributes;
use List::Util qw(first);
use List::MoreUtils ();
use Scalar::Util qw(blessed);
use JSON ();
use CatalystX::Controller::ExtJS::Direct::Route;
__PACKAGE__->config(
action => {
=> 'router' },
src => { Local => undef },
},
default => 'application/json'
);
has 'api' => ( is => 'rw', lazy_build => 1 );
has 'routes' => ( is => 'rw', isa => 'H
actions => $data
};
}
sub encoded_api {
my ( $self, $c ) = @_;
return JSON::encode_json( $self->set_namespace( $self->api, $c ? $c->req->params->{namespace} : () ) );
}
sub rout
CT: Sets the request method via a query parameter
use Moose::Role;
use namespace::autoclean;
use JSON::XS;
#has 'is_ext_upload' => ( isa => 'Bool', is => 'rw', lazy_build => 1 );
sub is_ext_upload
^multipart\/form-data/
&& ( !$self->{content_type} || $self->{content_type} ne 'application/json');
}
around 'method' => sub {
my ( $orig, $self, $method ) = @_;
return $self->$orig($me