JSON::RPC::Dispatcher::ClassMapping - Expose all public methods of classes as RPC methods
# in app.psgi use JSON::RPC::Dispatcher::ClassMapping; my $server = JSON::RPC::Dispatcher::ClassMapping->new( dispatch => { Foo => 'My::Module', Bar => 'My::Another::Module', }, ); $server->to_app;
This module is a wrapper for JSON::RPC::Dispatcher and provides an easy way to expose all public methods of classes as JSON-RPC methods. It treats methods with a leading underscore as private methods.
This is a hashref that maps "package names" in RPC method requests to actual Perl module names (in a format like My::Module::Name). For example, let's say that you have a dispatch that looks like this:
My::Module::Name
dispatch
{ 'Util' => 'Foo::Service::Util', 'Calendar' => 'Bar::Baz' }
So then, calling the method Util.get will call Foo::Service::Util->get. Calling Calendar.create will call Bar::Baz->create. You don't have to pre-load the Perl modules, JSON::RPC::Dispatcher::ClassMapping will load them for you.
Util.get
Foo::Service::Util->get
Calendar.create
Bar::Baz->create
Sherwin Daganato <sherwin@daganato.com>
Based on the dispatcher of RPC::Any::Server by Max Kanat-Alexander.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
RPC::Any::Server SOAP::Server
To install JSON::RPC::Dispatcher::ClassMapping, copy and paste the appropriate command in to your terminal.
cpanm
cpanm JSON::RPC::Dispatcher::ClassMapping
CPAN shell
perl -MCPAN -e shell install JSON::RPC::Dispatcher::ClassMapping
For more information on module installation, please visit the detailed CPAN module installation guide.