Steven Haryanto > Perinci-Access-0.31 > Perinci::Access

Download:
Perinci-Access-0.31.tar.gz

Dependencies

Annotate this POD

Website

View/Report Bugs
Module Version: 0.31   Source  

NAME ^

Perinci::Access - Wrapper for Perinci Riap clients

VERSION ^

version 0.31

SYNOPSIS ^

 use Perinci::Access;

 my $pa = Perinci::Access->new;
 my $res;

 # use Perinci::Access::InProcess
 $res = $pa->request(call => "pl:/Mod/SubMod/func");

 # ditto
 $res = $pa->request(call => "/Mod/SubMod/func");

 # use Perinci::Access::HTTP::Client
 $res = $pa->request(info => "http://example.com/Sub/ModSub/func",
                     {uri=>'/Sub/ModSub/func'});

 # use Perinci::Access::Simple::Client
 $res = $pa->request(meta => "riap+tcp://localhost:7001/Sub/ModSub/");

 # dies, unknown scheme
 $res = $pa->request(call => "baz://example.com/Sub/ModSub/");

DESCRIPTION ^

This module provides a convenient wrapper to select appropriate Riap client (Perinci::Access::*) objects based on URI scheme (or lack thereof).

 riap://perl/Foo/Bar/  -> InProcess
 /Foo/Bar/             -> InProcess
 pl:/Foo/Bar           -> InProcess
 http://...            -> HTTP::Client
 https://...           -> HTTP::Client
 riap+tcp://...        -> Simple::Client
 riap+unix://...       -> Simple::Client
 riap+pipe://...       -> Simple::Client

You can customize or add supported schemes by providing class name or object to the handlers attribute (see its documentation for more details).

VARIABLES ^

$Log_Request (BOOL)

Whether to log every Riap request. Default is from environment variable LOG_RIAP_REQUEST, or false. Logging is done with Log::Any at trace level.

$Log_Response (BOOL)

Whether to log every Riap response. Default is from environment variable LOG_RIAP_RESPONSE, or false. Logging is done with Log::Any at trace level.

METHODS ^

new(%opts) -> OBJ

Create new instance. Known options:

$pa->request($action, $server_url, \%extra, \%copts) -> RESP

Send Riap request to Riap server. Pass the request to the appropriate Riap client (as configured in handlers constructor options). RESP is the enveloped result.

%extra is optional, containing Riap request keys (the action request key is taken from $action).

%copts is optional, containing Riap-client-specific options. For example, to pass HTTP credentials to Perinci::Access::HTTP::Client, you can do:

 $pa->request(call => 'http://example.com/Foo/bar', {args=>{a=>1}},
              {user=>'admin', password=>'secret'});

ENVIRONMENT ^

LOG_RIAP_REQUEST

LOG_RIAP_RESPONSE

SEE ALSO ^

Perinci::Access::InProcess

Perinci::Access::HTTP::Client

Perinci::Access::Simple::Client

AUTHOR ^

Steven Haryanto <stevenharyanto@gmail.com>

COPYRIGHT AND LICENSE ^

This software is copyright (c) 2013 by Steven Haryanto.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

syntax highlighting: