faces are accessed over HTTP. That
interface will be REST based. They will return either HTML or JSON depending
on HTTP headers. The HTML interface will be a simple layer to the underlaying
api. Th
or REST based
applications.
=head2 VALIDATION
You also need to validate your input. Any posted JSON data is converted into a
L<Hash::MultiValue|https://metacpan.org/pod/Hash::MultiValue> object. Th
package XAS::Apps::Service::Testd;
use Template;
use JSON::XS;
use Web::Machine;
use Plack::Builder;
use Plack::App::File;
use Plack::App::URLMap;
use XAS::Service::Server;
use XAS::Class
version
rvices');
my $description = $self->cfg->val('app', 'description', 'Test api using RESTFUL HAL-JSON');
# Template config
my $config = {
INCLUDE_PATH => File($base, 'root')->path,
ext
};
# create various objects
my $template = Template->new($config);
my $json = JSON::XS->new->utf8();
# allow variables with preceeding _
$Template::Stash::PRIVATE =
gs->{'template'}
? $args->{'template'}
: undef;
$self->{'json'} = exists $args->{'json'}
? $args->{'json'}
: undef;
$self->{'app_name'} = exists $args->{'app_name'}
return 1;
}
sub content_types_accepted {
return [
{ 'application/json' => 'from_json' },
{ 'application/x-www-form-urlencoded' => 'from_html' },
];
}
su
{
return [
{ 'text/html' => 'to_html' },
{ 'application/hal+json' => 'to_json' },
];
}
sub charset_provided { return ['UTF-8']; }
sub finish_request {
my $se
ervice::CheckParameters',
accessors => 'profile',
utils => ':validation',
codec => 'JSON',
vars => {
PARAMS => {
-columns => { type => ARRAYREF },
}
}
;
use Data::Dump
a source is implemented with these parameters.
=over 4
=item B<sort>
This will be a serialized JSON data structure. This needs to be converted
into a Perl data structure. This data structure will b
source is implemented with these parameters.
=over 4
=item B<group>
This will be a serialized JSON data structure. This needs to be converted
into a Perl data structure. This data structure will b
on => $VERSION,
base => 'XAS::Base',
utils => ':validation dotid',
codec => 'JSON',
constants => 'HASHREF',
mixins => 'check_parameters',
;
#use Data::Dumper;
# ---------
ameters. It expects a "profile" method to be defined. Exceptions are thrown,
and the message is a JSON data structure of the errors.
=head2 check_parameters($params, $type)
A basic validation routin