Introducing JSON::RPC::Dispatcher
Have you ever needed to create an application server quickly? Maybe you tried SOAP? It's never a fun experience, and if you're like me you may have ended up reinventing the wheel a lot due to poor quality modules on CPAN, or confusing documentation. Today I'm announcing JSON::RPC::Dispatcher. It's a super easy way to create JSON RPC 2.0 web services. It's built on top of Plack so you can easily deploy it anywhere you need.
How easy is it to create an app server? This easy:
use JSON::RPC::Dispatcher;
my $rpc = JSON::RPC::Dispatcher->new;
sub add_em {
my @params = @_;
my $sum = 0;
$sum += $_ for @params;
return $sum;
}
$rpc->register( 'sum', \&add_em );
$rpc->to_app;
Voila, you've just exposed a subroutine to the network. You can then request it via a simple JSON post or get operation.
{"jsonrpc":"2.0","method":"sum","params":[2,3,5],"id":"1"}
But that's just basic. It also has JSON::RPC::Dispatcher::App, which allows you to create an object oriented app server in the same number of lines of code. And since it's built on top of the JSON-RPC 2.0 standard, you can interact with it using any of the numerous JSON-RPC 2.0 clients available for dozens of different languages out there, including Perl!
Have you seen JSORB?
http://search.cpan.org/~stevan/JSORB-0.04/lib/JSORB.pm
I hadn't seen that, no, but thanks for pointing it out. It looks like it's a lot more complicated than JSON::RPC::Dispatcher, both good (automatic type constraint checking), and bad (more code to get up and running).
It also doesn't appear to be a valid implementation of JSON-RPC 2.0. Perhaps valid isn't the correct term, maybe "complete" would be a better term.
That said, JSORB certainly seems like an interesting project. I'll definitely keep my eyes on it. Thanks for the heads up.
As far as I've seen, JSORB is currently used primarily in KiokuDB::Navigator.
It provides introspection into Moose objects and automating stuff like that, which you obviously, don't really want/care/need to implement in yours.
Yours seems like a more concise and generic JSON::RPC implementation which is unique and.. well, awesome! :)