perlancar > Perinci-Access-Perl-0.84 > Perinci::Access::Schemeless



Annotate this POD


View/Report Bugs
Module Version: 0.84   Source  


Perinci::Access::Schemeless - Base class for Perinci::Access::Perl


This document describes version 0.84 of Perinci::Access::Schemeless (from Perl distribution Perinci-Access-Perl), released on 2015-09-03.


This class is the base class for Perinci::Access::Perl, and by default acts like Perinci::Access::Perl (e.g. given uri /Foo/Bar/baz it will refer to function baz in Perl package Foo::Bar; it also looks for Rinci metadata in %SPEC package variables by default). But this class is designed to be flexible: you can override aspects of it so it can map uri to different Perl packages (e.g. using option like package_prefix), you can retrieve Rinci metadata from a database or whatever, etc.

Supported features:

How request is processed

User calls $pa->request($action => $uri, \%extras). Internally, the method creates a hash $req which contains Riap request keys as well as internal information about the Riap request (the latter will be prefixed with dash -). Initially it will contain action and uri and the %extras keys from the request() arguments sent by the user.

Internal _parse_uri() method will be called to parse uri into -uri_dir (the "dir" part), -uri_leaf (the "basename" part), and -perl_package. Forbidden or invalid paths will cause this method to return an enveloped error response and the request to stop. For example, if uri is /Foo/Bar/ then -uri_dir is /Foo/Bar/ and -uri_leaf is an empty string. If uri is /Foo/Bar/baz then -uri_dir is /Foo/Bar/ while -uri_leaf is baz. -uri_dir will be used for the list action. In both cases, -perl_package will be set to Foo::Bar.

The code entity type is then determined currently using a few simple heuristic rules: if -uri_leaf is empty string, type is package. If -uri_leaf begins with [$%@], type is variable. Otherwise, type is function. -type will be set.

After this, the appropriate action_ACTION() method will be called. For example if action is meta then action_meta() method will be called, with $req as the argument. This will in turn, depending on the action, either call get_meta() (for example if action is meta) or get_code() (for example if action is call), also with $req as the argument. get_meta() and get_code() should return nothing on success, and set either -meta (a defhash containing Rinci metadata) or -code (a coderef), respectively. On error, they must return an enveloped error response.

get_meta() or get_code() might call _load_module() to load Perl modules if the load attribute is set to true.


PKG->new(%attrs) => OBJ

Instantiate object. Known attributes:

$pa->request($action => $server_url, \%extra) => $res

Process Riap request and return enveloped result. $server_url will be used as the Riap request key 'uri', as there is no server in this case.

$pa->parse_url($server_url) => HASH


This class might add the following property/attribute in result metadata:

x.hint.result_binary => bool

If result's schema type is buf, then this class will set this attribute to true, to give hints to result formatters.


Riap, Rinci


Please visit the project's homepage at


Source repository is at


Please report any bugs or feature requests on the bugtracker website

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.


perlancar <>


This software is copyright (c) 2015 by

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: