-
-
24 Feb 2021 11:04:26 UTC
- Distribution: MojoX-JSON-RPC
- Source (raw)
- Browse (raw)
- Changes
- How to Contribute
- Repository
- Issues (9)
- Testers (204 / 0 / 0)
- Kwalitee
Bus factor: 1- 80.90% Coverage
- License: artistic_2
- Activity
24 month- Tools
- Download (16.59KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
and 1 contributors-
Henry Tang
- Dependencies
- Mojolicious
- and possibly others
- Reverse dependencies
- CPAN Testers List
- Dependency graph
NAME
MojoX::JSON::RPC::Dispatcher::Method - The data holder between RPC requests and responses.
SYNOPSIS
use MojoX::JSON::RPC::Dispatcher::Method; my $meth = MojoX::JSON::RPC::Dispatcher::Method->new( method => 'sum', id => 1 ); $meth->error_code(300);
DESCRIPTION
This module is heavily inspired by JSON::RPC::Dispatcher::Procedure.
ATTRIBUTES
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.
METHODS
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;
SEE ALSO
MojoX::JSON::RPC::Dispatcher, JSON::RPC::Dispatcher::Procedure
Module Install Instructions
To install MojoX::JSON::RPC, copy and paste the appropriate command in to your terminal.
cpanm MojoX::JSON::RPC
perl -MCPAN -e shell install MojoX::JSON::RPC
For more information on module installation, please visit the detailed CPAN module installation guide.