Group
Extension

Matches 35358

WebAPI-DBIC ( T/TI/TIMB/WebAPI-DBIC-0.004002.tar.gz, TIMB, 2015; MetaCPAN )
WebAPI-DBIC/lib/WebAPI/DBIC/Resource/Role/DBICParams.pm ( view source; MetaCPAN )
 # Noramalise all prefetches to most complicated form.
    # eg &prefetch=foo,bar  or  &prefetch.json={...}
    my $prefetch = $self->_resolve_prefetch($value, $self->set->result_source);

    return
WebAPI-DBIC ( T/TI/TIMB/WebAPI-DBIC-0.004002.tar.gz, TIMB, 2015; MetaCPAN )
WebAPI-DBIC/lib/WebAPI/DBIC/Resource/Role/Item.pm ( view source; MetaCPAN )
e;


requires 'render_item_as_plain_hash';
requires 'id_unique_constraint_name';
requires 'encode_json';
requires 'set';


has id => (         # array of 1 or more key values from url path
   is => 'r
ent_types_provided {
    return [ { 'application/vnd.wapid+json' => 'to_json_as_plain' } ]
}

sub to_json_as_plain { return $_[0]->encode_json($_[0]->render_item_as_plain_hash($_[0]->item)) }

sub res
WebAPI-DBIC ( T/TI/TIMB/WebAPI-DBIC-0.004002.tar.gz, TIMB, 2015; MetaCPAN )
WebAPI-DBIC/lib/WebAPI/DBIC/Resource/Role/SetInvoke.pm ( view source; MetaCPAN )
RSION = '0.004002';

use Scalar::Util qw(blessed);

use Moo::Role;


requires 'decode_json';
requires 'encode_json';
requires 'render_item_as_plain_hash';
requires 'throwable';
requires 'set';

has me
uest content-type not application/json")
        unless $self->request->header('Content-Type') =~ 'application/.*?json';
    my $invoke_body_data = $self->decode_json($self->request->content);
    $se
lf->throwable->throw_bad_request(400, errors => "Request content not a JSON hash")
        unless ref $invoke_body_data eq 'HASH';

    my @method_args;
    if (my $args = delete $invoke_body_data->{a
WebAPI-DBIC ( T/TI/TIMB/WebAPI-DBIC-0.004002.tar.gz, TIMB, 2015; MetaCPAN )
WebAPI-DBIC/lib/WebAPI/DBIC/Resource/Role/ItemWritable.pm ( view source; MetaCPAN )
 confess);
use Devel::Dwarn;

use Moo::Role;


requires 'render_item_into_body';
requires 'decode_json';
requires 'item';
requires 'param';
requires 'prefetch';
requires 'request';
requires 'response'
epted {
    return [ {'application/vnd.wapid+json' => 'from_plain_json'} ]
}


sub from_plain_json {
    my $self = shift;
    my $data = $self->decode_json( $self->request->content );
    $self->upda
WebAPI-DBIC ( T/TI/TIMB/WebAPI-DBIC-0.004002.tar.gz, TIMB, 2015; MetaCPAN )
WebAPI-DBIC/lib/WebAPI/DBIC/Resource/Role/Root.pm ( view source; MetaCPAN )
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 
WebAPI-DBIC ( T/TI/TIMB/WebAPI-DBIC-0.004002.tar.gz, TIMB, 2015; MetaCPAN )
WebAPI-DBIC/lib/WebAPI/DBIC/Resource/HAL/Role/Set.pm ( view source; MetaCPAN )
use Moo::Role;

use Carp qw(confess);

requires '_build_content_types_provided';
requires 'encode_json';
requires 'render_set_as_hal';
requires 'set';


around '_build_content_types_provided' => sub {
>$orig();
    unshift @$types, { 'application/hal+json' => 'to_json_as_hal' };
    return $types;
};


sub to_json_as_hal   { return $_[0]->encode_json($_[0]->render_set_as_hal(  $_[0]->set)) }


1;

ts representing set resources, e.g.
the rows of a database table.

Supports the C<application/hal+json> content type.

=head1 NAME

WebAPI::DBIC::Resource::HAL::Role::Set - add HAL content type suppor
WebAPI-DBIC ( T/TI/TIMB/WebAPI-DBIC-0.004002.tar.gz, TIMB, 2015; MetaCPAN )
WebAPI-DBIC/lib/WebAPI/DBIC/Resource/Role/SetWritable.pm ( view source; MetaCPAN )
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
WebAPI-DBIC ( T/TI/TIMB/WebAPI-DBIC-0.004002.tar.gz, TIMB, 2015; MetaCPAN )
WebAPI-DBIC/lib/WebAPI/DBIC/Resource/Role/DBIC.pm ( view source; MetaCPAN )
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))[
zhangbo-NLP-plugin_eng ( Z/ZH/ZHANGBO/zhangbo-NLP-plugin_eng-0.002.tar.gz, ZHANGBO, 2015; MetaCPAN )
zhangbo-NLP-plugin_eng/lib/zhangbo/NLP/engine_article2_jieba_babel_multi_2.2_gongan_ok.pl ( view source; MetaCPAN )
#!/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;
#
WebAPI-DBIC ( T/TI/TIMB/WebAPI-DBIC-0.004002.tar.gz, TIMB, 2015; MetaCPAN )
WebAPI-DBIC/lib/WebAPI/HTTP/Throwable/Role/JSONBody.pm ( view source; MetaCPAN )
package WebAPI::HTTP::Throwable::Role::JSONBody;
$WebAPI::HTTP::Throwable::Role::JSONBody::VERSION = '0.004002';
use Moo::Role;

sub body { return shift->message }

sub body_headers {
    my ($self, $
plication/json',
        'Content-Length' => length $body,
    ];
}

sub as_string { return shift->body }

1;

__END__

=pod

=encoding UTF-8

=head1 NAME

WebAPI::HTTP::Throwable::Role::JSONBody

=he
C<application/json> content type and will send the
C<message> attribute as the response body.  C<message> should be a
valid JSON string.

=head1 NAME

WebAPI::HTTP::Throwable::Role::JSONBody - an exce
WebAPI-DBIC ( T/TI/TIMB/WebAPI-DBIC-0.004002.tar.gz, TIMB, 2015; MetaCPAN )
WebAPI-DBIC/lib/WebAPI/DBIC/Resource/HAL/Role/SetWritable.pm ( view source; MetaCPAN )
e;


requires '_build_content_types_accepted';
requires 'render_item_into_body';
requires 'decode_json';
requires 'set';
requires 'prefetch';


around '_build_content_types_accepted' => sub {
    my $
 { 'application/hal+json' => 'from_hal_json' };
    return $types;
};


sub from_hal_json {
    my $self = shift;
    my $item = $self->create_resources_from_hal( $self->decode_json($self->request->co
resources, e.g. to insert
rows into a database table.

Supports the C<application/hal+json> and C<application/json> content types.

=head1 NAME

WebAPI::DBIC::Resource::HAL::Role::SetWritable - method
WebAPI-DBIC ( T/TI/TIMB/WebAPI-DBIC-0.004002.tar.gz, TIMB, 2015; MetaCPAN )
WebAPI-DBIC/lib/WebAPI/DBIC/Resource/JSONAPI/Role/Item.pm ( view source; MetaCPAN )
:Resource::JSONAPI::Role::Item;
$WebAPI::DBIC::Resource::JSONAPI::Role::Item::VERSION = '0.004002';

use Moo::Role;


requires '_build_content_types_provided';
requires 'render_item_as_jsonapi_hash';
_json';
requires 'item';


around '_build_content_types_provided' => sub {
    my $orig = shift;
    my $self = shift;
    my $types = $self->$orig();
    unshift @$types, { 'application/vnd.api+json'
 => 'to_json_as_jsonapi' };
    return $types;
};

#sub to_json_as_jsonapi { return $_[0]->encode_json($_[0]->render_item_as_jsonapi_hash($_[0]->item)) }
sub to_json_as_jsonapi {
    my $self = shift;
WebAPI-DBIC ( T/TI/TIMB/WebAPI-DBIC-0.004002.tar.gz, TIMB, 2015; MetaCPAN )
WebAPI-DBIC/lib/WebAPI/DBIC/Resource/JSONAPI/Role/DBIC.pm ( view source; MetaCPAN )
PI::DBIC::Resource::JSONAPI::Role::DBIC;
$WebAPI::DBIC::Resource::JSONAPI::Role::DBIC::VERSION = '0.004002';

use Carp qw(croak confess);
use Devel::Dwarn;
use JSON::MaybeXS qw(JSON);

use Moo::Role;
'path_for_item';
requires 'add_params_to_url';
requires 'prefetch';
requires 'type_namer';



sub jsonapi_type {
    my ($self) = @_;
    return $self->type_namer->type_name_for_resultset($self->set);
= $rel_info->{class}||die "panic";

    my $rel_jsonapi_type = $self->type_namer->type_name_for_result_class($result_class);

    my $path = $self->jsonapi_type .".". $relname;
    return $path => {
 
WebAPI-DBIC ( T/TI/TIMB/WebAPI-DBIC-0.004002.tar.gz, TIMB, 2015; MetaCPAN )
WebAPI-DBIC/lib/WebAPI/DBIC/Resource/JSONAPI/Role/ItemWritable.pm ( view source; MetaCPAN )
rce::JSONAPI::Role::ItemWritable;
$WebAPI::DBIC::Resource::JSONAPI::Role::ItemWritable::VERSION = '0.004002';

use Carp qw(croak confess);
use Devel::Dwarn;

use Moo::Role;


requires 'decode_json';
r
ion/vnd.api+json' => 'from_jsonapi_json' };
    return $types;
};


sub from_jsonapi_json {
    my $self = shift;
    $self->_pre_update_resource_method( "_do_update_embedded_resources_jsonapi" );
   
elf->decode_json( $self->request->content );
    $self->update_resource($data, is_put_replace => 0);
    return;
}


sub _do_update_embedded_resources_jsonapi {
    my ($self, $item, $jsonapi, $result
WebAPI-DBIC ( T/TI/TIMB/WebAPI-DBIC-0.004002.tar.gz, TIMB, 2015; MetaCPAN )
WebAPI-DBIC/lib/WebAPI/DBIC/Resource/JSONAPI/Role/Set.pm ( view source; MetaCPAN )
rce::JSONAPI::Role::Set;
$WebAPI::DBIC::Resource::JSONAPI::Role::Set::VERSION = '0.004002';

use Moo::Role;

use Carp qw(confess);

requires '_build_content_types_provided';
requires 'encode_json';
re
quires 'set';
requires 'render_jsonapi_response';
requires 'jsonapi_type';


around '_build_content_types_provided' => sub {
    my $orig = shift;
    my $self = shift;
    my $types = $self->$orig();
 { 'application/vnd.api+json' => 'to_json_as_jsonapi' };
    return $types;
};


sub to_json_as_jsonapi {
    my $self = shift;
    return $self->encode_json( $self->render_jsonapi_response() );
}


1
WebAPI-DBIC ( T/TI/TIMB/WebAPI-DBIC-0.004002.tar.gz, TIMB, 2015; MetaCPAN )
WebAPI-DBIC/lib/WebAPI/DBIC/Resource/JSONAPI/Role/SetWritable.pm ( view source; MetaCPAN )
package WebAPI::DBIC::Resource::JSONAPI::Role::SetWritable;
$WebAPI::DBIC::Resource::JSONAPI::Role::SetWritable::VERSION = '0.004002';

use Devel::Dwarn;
use Carp qw(confess);

use Moo::Role;


requir
es '_build_content_types_accepted';
requires 'render_item_into_body';
requires 'decode_json';
requires 'set';
requires 'prefetch';


around '_build_content_types_accepted' => sub {
    my $orig = shif
ation/vnd.api+json' => 'from_jsonapi_json' };
    return $types;
};


sub from_jsonapi_json {
    my $self = shift;
    my $item = $self->create_resources_from_jsonapi( $self->decode_json($self->reque
WebAPI-DBIC ( T/TI/TIMB/WebAPI-DBIC-0.004002.tar.gz, TIMB, 2015; MetaCPAN )
WebAPI-DBIC/lib/WebAPI/DBIC/Resource/HAL/Role/Item.pm ( view source; MetaCPAN )
de_json';
requires 'item';


around '_build_content_types_provided' => sub {
    my $orig = shift;
    my $self = shift;
    my $types = $self->$orig();
    unshift @$types, { 'application/hal+json' =
> 'to_json_as_hal' };
    return $types;
};

sub to_json_as_hal { return $_[0]->encode_json($_[0]->render_item_as_hal_hash($_[0]->item)) }

1;

__END__

=pod

=encoding UTF-8

=head1 NAME

WebAPI::DBI
 VERSION

version 0.004002

=head1 DESCRIPTION

Provides methods to support the C<application/hal+json> media type
for GET and HEAD requests for requests representing individual resources,
e.g. a sing
WebAPI-DBIC ( T/TI/TIMB/WebAPI-DBIC-0.004002.tar.gz, TIMB, 2015; MetaCPAN )
WebAPI-DBIC/lib/WebAPI/DBIC/Resource/HAL/Role/DBIC.pm ( view source; MetaCPAN )
HAL::Role::DBIC::VERSION = '0.004002';

use Carp qw(croak confess);
use Devel::Dwarn;
use JSON::MaybeXS qw(JSON);

use Moo::Role;


requires 'get_url_for_item_relationship';
requires 'render_item_as_p
e => $curie,
         href => "http://docs.acme.com/relations/{rel}", # XXX
         templated => JSON->true,
       }];
   }

    return $data;
}


sub _render_prefetch {
    my ($self, $item, $data,
d
        # resource and not the parent."
        # See http://blog.stateless.co/post/13296666138/json-linking-with-hal
        if (not defined $subitem) {
            $data->{_embedded}{$rel} = undef
WebAPI-DBIC ( T/TI/TIMB/WebAPI-DBIC-0.004002.tar.gz, TIMB, 2015; MetaCPAN )
WebAPI-DBIC/lib/WebAPI/DBIC/Resource/HAL/Role/Root.pm ( view source; MetaCPAN )
:Role::Root::VERSION = '0.004002';

use Moo::Role;

use JSON::MaybeXS qw(JSON);

requires '_build_content_types_provided';
requires 'encode_json';


around '_build_content_types_provided' => sub {
   
->$orig();
    unshift @$types, { 'application/hal+json' => 'to_json_as_hal' };
    return $types;
};


sub to_json_as_hal { return $_[0]->encode_json($_[0]->render_api_as_hal()) }


sub render_api_as
->env->{REQUEST_URI}; # "/clients/v1/";

    # we get here when the HAL Browser requests the root JSON
    my %links = (self => { href => $path } );
    foreach my $route (@{$router->routes})  {
     
WebAPI-DBIC ( T/TI/TIMB/WebAPI-DBIC-0.004002.tar.gz, TIMB, 2015; MetaCPAN )
WebAPI-DBIC/lib/WebAPI/DBIC/Resource/HAL/Role/ItemWritable.pm ( view source; MetaCPAN )
N = '0.004002';

use Carp qw(croak confess);
use Devel::Dwarn;

use Moo::Role;


requires 'decode_json';
requires 'request';

requires '_pre_update_resource_method';


around '_build_content_types_acc
 $types = $self->$orig();
    unshift @$types, { 'application/hal+json' => 'from_hal_json' };
    return $types;
};


sub from_hal_json {
    my $self = shift;
    $self->_pre_update_resource_method( 
"_do_update_embedded_resources_hal" );
    my $data = $self->decode_json( $self->request->content );
    $self->update_resource($data, is_put_replace => 0);
    return;
}


sub _do_update_embedded_res

Powered by Groonga
Maintained by Kenichi Ishigaki <ishigaki@cpan.org>. If you find anything, submit it on GitHub.