package JSON::RPC::Lite;
use strict;
use warnings;
use version; our $VERSION = version->declare("v1.0.0");
use JSON::RPC::Spec;
use Plack::Request;
sub import {
my $pkg = caller(0);
my $
rpc = JSON::RPC::Spec->new;
my $method = sub ($$) {
$rpc->register(@_);
};
no strict 'refs';
*{"${pkg}::method"} = $method;
*{"${pkg}::as_psgi_app"} = sub {
my $body = $rpc->parse($req->content);
my $header = ['Content-Type' => 'application/json'];
if (length $body) {
return [200, $header, [$body]];
}