MojoX::JSON::RPC::Dispatcher - A JSON-RPC 2.0 server for Mojolicious
# lib/your-application.pm use base 'Mojolicious'; use MojoX::JSON::RPC::Service; sub startup { my $self = shift; my $svc = MojoX::JSON::RPC::Service->new; $svc->register( 'sum', sub { my @params = @_; my $sum = 0; $sum += $_ for @params; return $sum; } ); $self->plugin( 'json_rpc_dispatcher', services => { '/jsonrpc' => $svc } ); }
Using this module you can handle JSON-RPC 2.0 requests within Mojolicious.
MojoX::JSON::RPC::Dispatcher inherits all attributes from Mojolicious::Controller and implements the following attributes.
json
JSON encoder / decoder
error_code
Error code.
error_message
Error message.
error_data
Error data.
id
MojoX::JSON::RPC::Dispatcher inherits all methods from Mojolicious::Controller and implements the following new ones.
call
Process JSON-RPC call.
MojoX::JSON::RPC, Mojolicious::Plugin::JsonRpcDispatcher
To install MojoX::JSON::RPC, copy and paste the appropriate command in to your terminal.
cpanm
cpanm MojoX::JSON::RPC
CPAN shell
perl -MCPAN -e shell install MojoX::JSON::RPC
For more information on module installation, please visit the detailed CPAN module installation guide.