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 Smart::Comments;
use Data::Dumper;
our $rule;
our $fac
#!/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;
#u
#!/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;
#
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
WP::UserAgent;
use HTTP::Response;
use HTTP::Request::Common qw(DELETE POST GET);
use JSON::XS;
use MIME::Base64;
use Kavorka qw( multi method );
has 'ua' => (is => 'ro', def
st_request_at?,
Maybe[Bool] :$new_session?) {
my $json_content = {
signed_up_at => $signed_up_at,
name => $name,
las
$json_content->{user_id} = $user_id;
}
if (defined($email)) {
$json_content->{email} = $email;
}
if (defined($id)) {
$json_content->{
cket;
use Data::Dumper;
use lib "./";
use plugin_eng;
use POE qw(Component::Server::TCP);
#use JSON::XS;
use Clone qw(clone);
use Encode;
our @rewrite_g;
our @rewrite_l;
our @rewrite_n;
our %re
#!/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
cket;
use Data::Dumper;
use lib "./";
use plugin_eng;
use POE qw(Component::Server::TCP);
#use JSON::XS;
use Clone qw(clone);
use Encode;
our @rewrite_g;
our @rewrite_l;
our @rewrite_n;
our %re
also WebAPI::HTTP::Throwable::Role::JSONBody
use strict;
use warnings;
use parent 'HTTP::Throwable::Factory';
use Carp qw(carp cluck);
use JSON::MaybeXS qw(JSON);
sub extra_roles {
return (
'WebAPI::HTTP::Throwable::Role::JSONBody', # remove HTTP::Throwable::Role::TextBody
'StackTrace::Auto'
);
}
sub throw_bad_request {
my ($class, $status, %opts) = @_;
cluc
$json_body = JSON->new->ascii->pretty->encode($data);
# [ 'Content-Type' => 'application/hal+json' ],
$class->throw( BadRequest => {
status_code => $status,
message => $json_
#!/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;
# http://po
_json';
requires 'render_item_as_plain_hash';
has content_types_provided => (
is => 'lazy',
);
sub _build_content_types_provided {
return [ { 'application/vnd.wapid+json' => 'to_plain_json'
} ]
}
sub to_plain_json { return $_[0]->encode_json($_[0]->render_set_as_plain($_[0]->set)) }
sub allowed_methods { return [ qw(GET HEAD) ] }
# Avoid complaints about $set:
## no critic (NamingConv
quests representing set resources, e.g.
the rows of a database table.
Supports the C<application/json> content type.
=head1 NAME
WebAPI::DBIC::Resource::Role::Set - methods related to handling requ
v4版本基础上,合并了前4个相似中心词2个以上的类
use Algorithm::Kmeanspp;
#use JSON::XS;
use Clone qw(clone);
use MongoDB;
use Smart::Comments;
use lib "/home/wuyabo/shell/";
us
!/usr/bin/perl
#词词距离计算
#输入为:
#老虎
#鲜花
#月亮
#狮子
use POSIX;
#use JSON::XS;
use Clone qw(clone);
use MongoDB;
use Smart::Comments;
use lib "/home/wyb/shell/";
#use
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
rks
# http://geocoding.geo.census.gov/geocoder/vintages?benchmark=<id>
# with Accept: application/json
sub query {
my $class = shift;
my %opt = (
returntype => 'geographies',
benchmark =>
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
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
#!/usr/bin/perl
use Algorithm::Kmeanspp;
#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;
#us