MojoX::...:Method(3)

πŸ“¦
version 0.13 Β· 2 versions
, in fedora 43

πŸ’– 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::Dispatcher
  • JSON::RPC::Dispatcher::Procedure

lowkey reminder: this whole page came from the User Contributed Perl Documentation, it's perl v5.42.0, and the date on it is 2025-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