MojoX::...:Method(3)
π MojoX::JSON::RPC::Dispatcher::Method π
okay bestie, welcome to MojoX::JSON::RPC::Dispatcher::Method, which lives in the User Contributed Perl Documentation corner of the perl universe and is literally the data holder that sits between your RPC requests and your RPC responses. that's the whole job. it holds the vibes. it holds the data. it does not hold a grudge. π«Ά
β¨ SYNOPSIS β¨
use MojoX::JSON::RPC::Dispatcher::Method;
my $meth = MojoX::JSON::RPC::Dispatcher::Method->new(
method => 'sum',
id => 1
);
$meth->error_code(300);
see how easy that was?? make a $meth, give it a method and an id, then set an error_code like it's nothing. no cap. π
πΈ DESCRIPTION πΈ
this module is heavily inspired by JSON::RPC::Dispatcher::Procedure. that's it, that's the lore. it's giving "I learned everything I know from my icon" and honestly? respect. π
π ATTRIBUTES π
MojoX::JSON::RPC::Dispatcher::Method implements the following attributes. yes, all of them. every single one. we don't skip here. β¨
"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. so you get the family recipes and the new stuff. main character energy fr fr. π
"clear_error"
Clear error code, message and data. poof. gone. clean slate, fresh start, new era. π¦
"error"
Set error code and message. Optionally set some error data.
$proc->error(-32602, 'Invalid params');
$proc->error(-32603, 'Internal error.', '...');
code, message, and maybe a lil extra data if you're feeling generous. π
"has_error"
Returns a boolean indicating whether an error code has been set. basically the vibe check for "did something go wrong". π
"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;
this is the glow-up moment bestie β your lil object data gets formatted into the shape the client is expecting. iconic behavior. β
π SEE ALSO π
MojoX::JSON::RPC::DispatcherJSON::RPC::Dispatcher::Procedure
lowkey reminder: this whole page came from the User Contributed Perl Documentation, it'sperl v5.42.0, and the date on it is2025-07-25. so if you're reading this in the future, hi, hope the perl still slaps. π
later bestie, go hold some data between a request and a response, you're gonna ate πβ¨
π¦ where this page comes from
- fedora 43: perl-MojoX-JSON-RPC 0.13-14.fc43 Β· Artistic-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms