#!/usr/bin/perl
use POE qw(Component::Server::TCP);
#use JSON::XS;
use Clone qw(clone);
#use MongoDB;
#use Smart::Comments;
#use lib "/home/wuyabo/shell/";
#use Conn_mongo_jc;
#use Data::Dumper;
#
#!/usr/bin/perl
use POE qw(Component::Server::TCP);
#use JSON::XS;
use Clone qw(clone);
#use MongoDB;
#use Smart::Comments;
#use lib "/home/wuyabo/shell/";
#use Conn_mongo_jc;
#use Data::Dumper;
#
# Enable JSON API support:
'WebAPI::DBIC::Resource::JSONAPI::Role::DBIC', # XXX move out?
'WebAPI::DBIC::Resource::JSONAPI::Role::Set',
'WebAPI::DBIC::Resource::JSONAPI::Role:
kage WebAPI::DBIC::Resource::JSONAPI;
$WebAPI::DBIC::Resource::JSONAPI::VERSION = '0.004002';
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
WebAPI::DBIC::Resource::JSONAPI
=head1 VERSION
version
bAPI::DBIC::Resource::JSONAPI - JSON API support for WebAPI::DBIC
=head2 Media Type
These roles respond to the C<application/vnd.api+json> media type.
=head2 JSONAPI
The JSON API media type is des
compromising readability, flexibility, and discoverability.
See L<http://jsonapi.org/> for more details.
Development of JSON API support for WebAPI::DBIC has stalled due to instability
of the specif
WebAPI::DBIC (or "WAPID" for short) provides the parts you need to build a
feature-rich RESTful JSON web service API backed by DBIx::Class schemas.
WebAPI::DBIC features include:
* Built as fine-g
ding ActiveModel / Ember-Data
(C<application/json>), JSON API (C<application/vnd.api+json>)
and HAL (C<application/hal+json>).
The Collection+JSON and JSON-LD hypermedia types could be added in future
dia type' of a request, and the desired response. In the case of JSON
types, the media type defines not only that the content is a JSON data structure,
but the semantics (meaning) of the the scructure
# Enable JSON API support:
'WebAPI::DBIC::Resource::JSONAPI::Role::DBIC',
'WebAPI::DBIC::Resource::JSONAPI::Role::Item',
'WebAPI::DBIC::Resource::JSONAPI::Role::ItemWr
type (or HAL for short)
is a simple JSON format that gives a consistent and easy way to hyperlink
between resources in your API. It uses the C<application/hal+json> media type.
Adopting HAL makes th
gramming languages. It's also simple
enough that you can just deal with it as you would any other JSON.
See L<http://stateless.co/hal_specification.html>
for more details of the specification.
=head
e Moo::Role;
requires 'render_set_as_plain';
requires 'render_item_into_body';
requires 'decode_json';
requires 'set';
requires 'prefetch';
requires 'writable';
requires 'path_for_item';
requires 'a
=> 'lazy',
);
sub _build_content_types_accepted {
return [ {'application/vnd.wapid+json' => 'from_plain_json'} ]
}
around 'allowed_methods' => sub {
my $orig = shift;
my $self = shift;
create_path_after_handler { return 1 }
sub from_plain_json {
my $self = shift;
my $item = $self->create_resource( $self->decode_json($self->request->content) );
return $self->item($item
equires 'encode_json';
has content_types_provided => (
is => 'lazy',
);
sub _build_content_types_provided {
return [
{ 'application/vnd.wapid+json' => 'to_plain_json' },
{ '
path");
return \302;
}
sub to_plain_json {
return $_[0]->encode_json($_[0]->render_root_as_plain());
}
sub render_root_as_plain { # informal JSON description, XXX liable to change
my
HEAD requests for requests representing the root resource, e.g. C</>.
Supports the C<application/json> content type.
=head1 NAME
WebAPI::DBIC::Resource::Role::Root - methods to handle requests for
rce::Role::DBIC::VERSION = '0.004002';
use Carp qw(croak confess);
use Devel::Dwarn;
use JSON::MaybeXS qw(JSON);
use Moo::Role;
requires 'uri_for';
requires 'throwable';
requires 'request';
requir
request->headers->header('Accept') =~ /hal\+json/) {
$body = $item_resource->to_json_as_hal;
}
else {
$body = $item_resource->to_json_as_plain;
}
$self->response->body
s = $self->request->query_parameters;
my @params = (%$override_params);
# XXX turns 'foo~json' into 'foo', and 'me.bar' into 'me'.
my %override_param_basenames = map { (split(/\W/,$_,2))[
rks
# http://geocoding.geo.census.gov/geocoder/vintages?benchmark=<id>
# with Accept: application/json
sub query {
my $class = shift;
my %opt = (
returntype => 'geographies',
benchmark =>
004002';
use Carp qw(croak confess);
use Scalar::Util qw(blessed);
use Devel::Dwarn;
use JSON::MaybeXS qw(JSON);
use Moo::Role;
requires 'response';
sub finish_request {
my ($self, $metadata
e formal error structure, such as
# application/vnd.error+json => https://github.com/blongden/vnd.error
my $json = JSON->new->ascii->pretty;
my $response = $self->response;
;
my $body = $json->encode($error_data);
$response->body($body);
$response->content_length(length $body);
$response->content_type('application/json');
}
else {
andling exceptions.
Specifically it should provide sufficient information to the client, via the
JSON response, to enable the client to update the form to indicate *which*
field(s) are associated wit
field information if possible.
Note that this may require some mapping of database field names to json entity
type field names.
=head1 CACHING
Implementing caching is easy. Implementing efficient c
-about-edge-side-includes/
http://stackoverflow.com/questions/11781576/most-secure-javascript-json-inline-technique
Also look into "Surrogate-Capability & Surrogate- Control headers for ESI based
ect;
use IO::Socket::INET;
use lib "./";
use plugin_eng;
use POE qw(Component::Server::TCP);
#use JSON::XS;
use Clone qw(clone);
use Encode;
#use MongoDB;
use Smart::Comments;
#use Conn_mongo_jc
ect;
use IO::Socket::INET;
use lib "./";
use plugin_eng;
use POE qw(Component::Server::TCP);
#use JSON::XS;
use Clone qw(clone);
use Encode;
#use MongoDB;
use Smart::Comments;
#use Conn_mongo_jc
#!/usr/bin/perl
#use JSON::XS;
use Clone qw(clone);
use MongoDB;
use Smart::Comments;
use lib "/home/wuyabo/shell/";
use Conn_mongo_jc;
use Data::Dumper;
use IO::File;
#use Add_info;
open(FDst,"s
#!/usr/bin/perl
#use JSON::XS;
use Clone qw(clone);
use MongoDB;
use Smart::Comments;
use lib "/home/wuyabo/shell/";
use Conn_mongo_jc;
use Data::Dumper;
use IO::File;
#use Add_info;
open(FDst,"stop
#!/usr/bin/perl
#use JSON::XS;
use Clone qw(clone);
use MongoDB;
use Smart::Comments;
use lib "/home/wyb/shell/";
use Conn_mongo_jc;
use Data::Dumper;
use IO::File;
#use Add_info;
# http://poe.p
#!/usr/bin/perl
use POE qw(Component::Server::TCP);
#use JSON::XS;
use Clone qw(clone);
#use MongoDB;
#use Smart::Comments;
#use lib "/home/wuyabo/shell/";
#use Conn_mongo_jc;
#use Data::Dumper;
#
ect;
use IO::Socket::INET;
use lib "./";
use plugin_eng;
use POE qw(Component::Server::TCP);
#use JSON::XS;
use Clone qw(clone);
use Encode;
#use MongoDB;
use Smart::Comments;
#use Conn_mongo_jc