The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Perinci::Access - Wrapper for Perinci Riap clients

VERSION

version 0.10

SYNOPSIS

 use Perinci::Access;

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

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

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

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

 # use Perinci::Access::TCP::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).

 /Foo/Bar/   -> InProcess
 pm:/Foo/Bar -> InProcess
 http://...  -> HTTP::Client
 https://... -> HTTP::Client
 riap+tcp:// -> TCP::Client

You can customize or add supported schemes by providing the .

METHODS

new(%opts) -> OBJ

Create new instance. Known options:

  • handlers (HASH)

    A mapping of scheme names and class names or objects. If values are class names, they will be require'd and instantiated. The default is:

     {
       pm         => 'Perinci::Access::InProcess',
       http       => 'Perinci::Access::HTTP::Client',
       https      => 'Perinci::Access::HTTP::Client',
       'riap+tcp' => 'Perinci::Access::TCP::Client',
     }

    Objects can be given instead of class names. This is used if you need to pass special options when instantiating the class.

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

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

SEE ALSO

Perinci, Riap

AUTHOR

Steven Haryanto <stevenharyanto@gmail.com>

COPYRIGHT AND LICENSE

This software is copyright (c) 2012 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.