Henry Tang > MojoX-JSON-RPC-0.05 > MojoX::JSON::RPC::Dispatcher

Download:
MojoX-JSON-RPC-0.05.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  4
Open  0
View/Report Bugs
Source   Latest Release: MojoX-JSON-RPC-0.06

NAME ^

MojoX::JSON::RPC::Dispatcher - A JSON-RPC 2.0 server for Mojolicious

SYNOPSIS ^

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

DESCRIPTION ^

Using this module you can handle JSON-RPC 2.0 requests within Mojolicious.

ATTRIBUTES ^

MojoX::JSON::RPC::Dispatcher inherits all attributes from Mojolicious::Controller and implements the following attributes.

json

JSON encoder / decoder

error_code

Error code.

error_message

Error message.

error_data

Error data.

id

METHODS ^

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

call

Process JSON-RPC call.

SEE ALSO ^

MojoX::JSON::RPC, Mojolicious::Plugin::JsonRpcDispatcher

syntax highlighting: