NAME
NetSDS::App::JSRPC - JSON-RPC server framework
SYNOPSIS
use 5.8.0;
JServer->run();
1;
package JServer;
use base 'NetSDS::App::JSRPC';
# This method is available via JSON-RPC
sub sum {
my ($self, $param) = @_;
return $$param[0] + $$param[1];
}
1;
DESCRIPTION
NetSDS::App::JSRPC
module implements framework for common JSON-RPC service.
This implementation is based on NetSDS::App::FCGI module and expected to be executed as FastCGI or CGI service.
Both request and response should be of 'application/x-json-rpc' MIME type.
CLASS API
- new([...]) - class constructor
- process() - main JSON-RPC iteration
-
This is internal method that implements JSON-RPC call processing.
- process_call($method, $params) - execute method call
-
Paramters: method name, parameters.
Returns parameters from executed method as is.
- _request_parse($post_data) - parse HTTP POST
-
Paramters: HTTP POST data as string
Returns: request method, parameters, id
- _make_result(%params) - prepare positive response
-
Paramters:
Returns JSON encoded response message
- _make_error(%params) - prepare error response
-
Internal method implementing error response.
Paramters:
- id - the same as request Id (see specification)
- code - error code (default is -32603, internal error)
- message - error message
Returns JSON encoded error message
EXAMPLES
See samples/app_jsrpc.fcgi
appliction.
BUGS
Unknown yet
SEE ALSO
TODO
* move error codes to constants
AUTHOR
Michael Bochkaryov <misha@rattler.kiev.ua>
LICENSE
Copyright (C) 2008-2009 Michael Bochkaryov
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA