-
-
04 Jan 2006 08:58:27 UTC
- Distribution: Catalyst-Plugin-JSONRPC
- Module version: 0.01
- Source (raw)
- Browse (raw)
- Changes
- How to Contribute
- Issues (1)
- Testers (76 / 714 / 0)
- Kwalitee
Bus factor: 1- 53.09% Coverage
- License: unknown
- Activity
24 month- Tools
- Download (3.19KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
- Dependencies
- Catalyst
- JSON
- Test::More
- and possibly others
- Reverse dependencies
- CPAN Testers List
- Dependency graph
NAME
Catalyst::Plugin::JSONRPC - Dispatch JSON-RPC methods with Catalyst
SYNOPSIS
# include it in plugin list use Catalyst qw/JSONRPC/; # Public action to redispatch sub entrypoint : Global { my ( $self, $c ) = @_; $c->json_rpc; } # Methods with Remote attribute in the same class sub echo : Remote { my ( $self, $c, @args ) = @_; return join ' ', @args; }
DESCRIPTION
Catalyst::Plugin::JSONRPC is a Catalyst plugin to add JSON-RPC methods in your controller class. It uses a same mechanism that XMLRPC plugin does and actually plays really nicely.
METHODS
- $c->json_rpc(%attrs)
-
Call this method from a controller action to set it up as a endpoint for RPC methods in the same class.
Supported attributes:
- class
-
name of class to dispatch (defaults to current one)
- method
-
method to dispatch to (overrides JSON-RPC method name)
REMOTE ACTION ATTRIBUTE
This module uses
Remote
attribute, which indicates that the action can be dispatched through RPC mechanisms. You can use thisRemote
attribute and integrate JSON-RPC and XML-RPC together, for example:sub xmlrpc_endpoint : Regexp('^xml-rpc$') { my($self, $c) = @_; $c->xmlrpc; } sub jsonrpc_endpoint : Regexp('^json-rpc$') { my($self, $c) = @_; $c->json_rpc; } sub add : Remote { my($self, $c, $a, $b) = @_; return $a + $b; }
Now
add
RPC method can be called either as JSON-RPC or XML-RPC.AUTHOR & LICENSE
Six Apart, Ltd. <cpan@sixapart.com>
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
THANKS
Thanks to Sebastian Riedel for his Catalyst::Plugin::XMLRPC, from which a lot of code is copied.
SEE ALSO
Catalyst::Plugin::XMLRPC,
JSON
,JSONRPC
Module Install Instructions
To install Catalyst::Plugin::JSONRPC, copy and paste the appropriate command in to your terminal.
cpanm Catalyst::Plugin::JSONRPC
perl -MCPAN -e shell install Catalyst::Plugin::JSONRPC
For more information on module installation, please visit the detailed CPAN module installation guide.