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 ($this, $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
None
TODO
* move error codes to constants
AUTHOR
Michael Bochkaryov <misha@rattler.kiev.ua>