MojoX::...patcher(3)

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

πŸ’– MojoX::JSON::RPC::Dispatcher πŸ’–

okay bestie, pull up a chair, because this is the page for MojoX::...patcher(3) from the User Contributed Perl Documentation, and honestly? it's a whole vibe. ✨


🌸 NAME 🌸

MojoX::JSON::RPC::Dispatcher β€” a JSON-RPC 2.0 server for Mojolicious. yes. that's the job. it serves. πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

here's the whole setup, copy-paste style, no cap:

# 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
        }
    );
}

look at that. registering a 'sum' service, wiring up the 'json_rpc_dispatcher' plugin with services => { '/jsonrpc' => $svc }. iconic behaviour, fr fr. 🫢


πŸ¦‹ DESCRIPTION πŸ¦‹

so the tea is: using this module you can handle JSON-RPC 2.0 requests within Mojolicious. that's it, that's the whole pitch. you get JSON-RPC 2.0 request handling, right inside Mojolicious, and it's giving main character energy. πŸ˜­πŸ’–


✨ ATTRIBUTES ✨

MojoX::JSON::RPC::Dispatcher inherits all attributes from Mojolicious::Controller (yes, all of them, the whole family tree 🌳) and implements the following attributes of its very own:

πŸ’« json

JSON encoder / decoder. she encodes. she decodes. she does it all. πŸ‘‘

πŸ’« error_code

Error code.

πŸ’« error_message

Error message.

πŸ’« error_data

Error data.

πŸ’« id

the id. just id. short, sweet, mysterious. 🌈


πŸ”₯ METHODS πŸ”₯

MojoX::JSON::RPC::Dispatcher inherits all methods from Mojolicious::Controller and implements the following new ones:

πŸ’œ call

Process JSON-RPC call. do it. slay. ⭐


πŸ‘‘ SEE ALSO πŸ‘‘

  • MojoX::JSON::RPC
  • Mojolicious::Plugin::JsonRpcDispatcher

go read those too, iykyk. πŸ“šβœ¨


lowkey reminder: everything above is exactly as the original says it β€” the attributes, the inheritance, the methods, the references. i'm just here to make it cute. πŸŽ€

okay that's the whole page, bestie!! this was perl v5.42.0, dated 2025-07-25, and it's from the User Contributed Perl Documentation. thanks for coming to my ted talk, mwah πŸ’‹πŸŒΈπŸ’–

πŸ“¦ where this page comes from