configming to spec: $@"
=item B<application/json>
If the B<body> is valid JSONRPC (ie. is has a I<'jsonrpc': '2.0'> field/value),
the response is a JSONRPC-error:
code => -32601
message =>
"Method '%s' not found"
If the B<body> is I<not> valid JSONRPC, the response is a generic json struct:
'error': {
'code': -32601,
'message': "Method '$request->path' not found"
elsif ( $content_type eq 'application/json' ) {
content_type('application/json');
my $request = request->body
? from_json(request->body, {allow_nonref => 1})
:Plugin::RPC::JSONRPC;
use v5.10;
use Dancer ':syntax';
use Dancer::Plugin;
use Scalar::Util 'blessed';
use Time::HiRes 'time';
our $VERSION = '1.09';
use constant PLUGIN_NAME => 'jsonrpc';
use Dan
debug("Starting jsonrpc-handler build: ", $lister);
my $handle_call = sub {
my ($ct) = (split /;\s*/, request->content_type, 2);
if ($ct ne 'application/json') {
pa
my @requests = unjson(request->body);
if (!exists($requests[0]->{jsonrpc}) or $requests[0]->{jsonrpc} ne "2.0") {
pass();
}
debug("[handle_jsonrpc_request] Proce
ub {
my ($ct) = (split /;\s*/, request->content_type, 2);
if ($ct ne 'application/json') {
pass();
}
debug("[handle_restrpc_request] Processing: ", request-
pass();
}
content_type 'application/json';
my $response;
my $method_args = request->body
? from_json(request->body)
: undef;
debug("[
nse } if !ref($response);
my $jsonise_options = {canonical => 1};
if (config->{encoding} && config->{encoding} =~ m{^utf-?8$}i) {
$jsonise_options->{utf8} = 1;
}
=head1 SYNOPSIS
use Dancer::RPCPlugin::DispatchItem;
use Dancer::Plugin::RPC::JSONRPC;
jsonrpc '/json' => {
publish => sub {
return {
'system.ping' =>