MojoX::JSON::RPC::Dispatcher::Method - The data holder between RPC requests and responses.
use MojoX::JSON::RPC::Dispatcher::Method; my $meth = MojoX::JSON::RPC::Dispatcher::Method->new( method => 'sum', id => 1 ); $meth->error_code(300);
This module is heavily inspired by JSON::RPC::Dispatcher::Procedure.
MojoX::JSON::RPC::Dispatcher::Method implements the following attributes.
id
Request id.
method
Request method name.
params
Request parameters.
result
Request result.
is_notification
Indicates whether request is a notification.
error_code
Error code.
error_message
Error message.
error_data
Error data.
MojoX::JSON::RPC::Dispatcher::Method inherits all methods from Mojo::Base and implements the following new ones.
clear_error
Clear error code, message and data.
error
Set error code and message. Optionally set some error data.
$proc->error(-32602, 'Invalid params'); $proc->error(-32603, 'Internal error.', '...');
has_error
Returns a boolean indicating whether an error code has been set.
internal_error
Sets an Internal Error as defined by the JSON-RPC 2.0 spec.
$proc->internal_error; $proc->internal_error('...');
invalid_params
Sets an Invalid Params error as defined by the JSON-RPC 2.0 spec.
$proc->invalid_params; $proc->invalid_params('...');
invalid_request
Sets an Invalid Request error as defined by the JSON-RPC 2.0 spec.
$proc->invalid_request; $proc->invalid_request('...');
method_not_found
Sets a Method Not Found error as defined by the JSON-RPC 2.0 spec.
$proc->method_not_found; $proc->method_not_found('...');
parse_error
Sets a Parse error as defined by the JSON-RPC 2.0 spec.
$proc->parse_error; $proc->parse_error('...');
response
Formats the data stored in this object into the data structure expected by MojoX::JSON::RPC::Dispatcher, which will ultimately be returned to the client.
my $res = $meth->response;
MojoX::JSON::RPC::Dispatcher, JSON::RPC::Dispatcher::Procedure
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.