JSON-RPC-Dispatcher

 view release on metacpan or  search on metacpan

author.t/01-parse-error.t  view on Meta::CPAN

use strict;
use warnings;
use lib '../lib';

use JSON qw(from_json to_json);
use JSON::RPC::Dispatcher;
use Test::More tests => 6;
use Test::WWW::Mechanize::PSGI;

my $rpc = JSON::RPC::Dispatcher->new;
my $endpoint = 'http://localhost';
my $mech = Test::WWW::Mechanize::PSGI->new(
    app => $rpc->to_app,
);

$rpc->register(echo => sub {
    return $_[0];
});

sub do_jsonrpc {
    my ( $content ) = @_;
    my $req = HTTP::Request->new(POST => $endpoint);
    $req->header('Content-type' => 'application/json');
    $req->header('Content-length' => length($content));
    $req->content($content);
    $mech->request($req);
}

do_jsonrpc(to_json({
    jsonrpc => '2.0',
    id => 0,
    method => 'echo',



( run in 1.115 second using v1.01-cache-2.11-cpan-524268b4103 )