NAME
MojoX::JSON::RPC::Dispatcher - A JSON-RPC 2.0 server for Mojolicious
SYNOPSIS
# 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
}
);
}
DESCRIPTION
Using this module you can handle JSON-RPC 2.0 requests within Mojolicious.
ATTRIBUTES
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
METHODS
MojoX::JSON::RPC::Dispatcher inherits all methods from Mojolicious::Controller and implements the following new ones.
call
Process JSON-RPC call.