NAME

Dancer2::RPCPlugin::CallbackResult - Factory for generating Callback-results.

SYNOPSIS

use Dancer2::Plugin::RPC::JSON;
use Dancer2::RPCPlugin::CallbackResultFactory;
jsonrpc '/admin' => {
    publish => 'config',
    callback => sub {
        my ($request, $rpc_method) = @_;
        if ($rpc_method =~ qr/^admin\.\w+$/) {
            return callback_success();
        }
        return callback_fail(
            error_code => -32768,
            error_message => "only admin methods allowed: $rpc_method",
        );
    },
};

DESCRIPTION

This module exports 2 factory subs: callback_success and callback_fail.

callback_success()

Allows no arguments.

Returns an instantiated Dancer::RPCPlugin::CallbackResult::Success object.

callback_fail(%arguments)

Allows these named arguments:

error_code => $code
error_message => $message

Returns an instantiated Dancer::RPCPlugin::CallbackResult::Fail object.

COPYRIGHT

© MMXXII - Abe Timmerman <abeltje@cpan.org>