JsonRpcHandler class definition; to be registered as a handler in the HttpServer class.
More...
#include <JsonRpcHandler.qm.dox.h>
Inherits AbstractHttpRequestHandler, and Logger::LoggerWrapper.
|
| void | constructor (soft< code > getLogMessage, bool dbg, soft< string > get_prefix, soft< list< auto > > methods, Logger::LoggerInterface logger, HttpServer::AbstractAuthenticator auth) |
| | Creates the handler with the given method list.
|
| |
| void | constructor (soft< code > getLogMessage, bool dbg, soft< code > log, HttpServer::AbstractAuthenticator auth, soft< list< auto > > methods, soft< string > get_prefix) |
| | Creates the handler with the given method list.
|
| |
| void | addMethod (soft< bool > include_context, auto cmark, auto logopt, string help, string text, string name, code func) |
| | adds a method to the handler dynamically
|
| |
|
void | addMethods (list< auto > methods) |
| | Add a list of methods.
|
| |
| bool | hasMethod (string text) |
| | Check if a method exists.
|
| |
|
list< string > | getMethodNames () |
| | Returns a list of method text names.
|
| |
|
void | setDebug (bool dbg) |
| | turns on or off debugging; when debugging is enabled more verbose error messages are reported
|
| |
|
bool | getDebug () |
| | returns the current status of the debug flag
|
| |
|
void | init (soft< list< auto > > methods, soft< code > getLogMessage, bool dbg, soft< string > get_prefix) |
| | Shared constructor code.
|
| |
|
|
const auto | Version = ... |
| | implementation of the handler
|
| |
|
const auto | InternalMethods = ... |
| | internal methods of the handler (introspection)
|
| |
|
const auto | JRE_ParseError = ... |
| | JSON-RPC Error Code: Parse Error.
|
| |
|
const auto | JRE_InvalidRequest = ... |
| | JSON-RPC Error Code: Invalid Request.
|
| |
|
const auto | JRE_MethodNotFound = ... |
| | JSON-RPC Error Code: Method not found.
|
| |
|
const auto | JRE_InvalidParams = ... |
| | JSON-RPC Error Code: Invalid Params.
|
| |
|
const auto | JRE_InternalError = ... |
| | JSON-RPC Error Code: Internal error.
|
| |
JsonRpcHandler class definition; to be registered as a handler in the HttpServer class.
◆ addMethod()
| void JsonRpcHandler::JsonRpcHandler::addMethod |
( |
soft< bool > |
include_context, |
|
|
auto |
cmark, |
|
|
auto |
logopt, |
|
|
string |
help, |
|
|
string |
text, |
|
|
string |
name, |
|
|
code |
func |
|
) |
| |
adds a method to the handler dynamically
- Parameters
-
| name | a regular expression to use for matching the method name |
| func | a string (giving a function name to call), a call reference, or a closure to call with the deserialized arguments to the method; the return value will be serialized to XML-RPC and sent back to the caller |
| text | the human-readable name of the method |
| help | help text for the method |
| logopt | log options which can be used by a custom logger (see the getLogMessage parameter) |
| cmark | any value that will be added in the method hash under the "cmark" key |
| include_context | if the call context argument should be included in the method call as the first argument |
◆ constructor() [1/2]
| void JsonRpcHandler::JsonRpcHandler::constructor |
( |
soft< code > |
getLogMessage, |
|
|
bool |
dbg, |
|
|
soft< code > |
log, |
|
|
HttpServer::AbstractAuthenticator |
auth, |
|
|
soft< list< auto > > |
methods, |
|
|
soft< string > |
get_prefix |
|
) |
| |
Creates the handler with the given method list.
- Parameters
-
| auth | an authentication object (use new AbstractAuthenticator() for no authentication) |
| methods | a list of hashes with the following keys:
name: a regular expression to use for matching the method name
function: a string (giving a function name to call), a call reference, or a closure to call with the deserialized arguments to the method; the return value will be serialized to JSON-RPC and sent back to the caller
text: the human-readable name of the method
help: help text for the method
logopt: (optional - by convention) log options which can be used by a custom logger (see the getLogMessage parameter)
cmark: (optional) a data structure to be added to the context argument when the request method is called
|
| getLogMessage | an optional closure or call reference to be called when an incoming request is received; if this is set then it will be called with the following arguments: a context hash (see HttpServer::AbstractHttpRequestHandler::handleRequest() for a description of the context hash), the method definition as passed in the methods argument to this constructor, and a reference to the arguments in this call |
| dbg | this parameter is set to True, then additional information will be logged when errors occur |
| get_prefix | prefix to add to derived methods with GET requests if no "." characters are in the path |
| log | an optional closure or call reference to be called when logging |
- Exceptions
-
| JSON-RPC-CONSTRUCTOR-ERROR | missing "name", "function", or "text" key in method hash,
\c "function" key not assigned to a callable value |
◆ constructor() [2/2]
| void JsonRpcHandler::JsonRpcHandler::constructor |
( |
soft< code > |
getLogMessage, |
|
|
bool |
dbg, |
|
|
soft< string > |
get_prefix, |
|
|
soft< list< auto > > |
methods, |
|
|
Logger::LoggerInterface |
logger, |
|
|
HttpServer::AbstractAuthenticator |
auth |
|
) |
| |
Creates the handler with the given method list.
- Parameters
-
| logger | the logger for the object |
| auth | an authentication object (use new AbstractAuthenticator() for no authentication) |
| methods | a list of hashes with the following keys:
name: a regular expression to use for matching the method name
function: a string (giving a function name to call), a call reference, or a closure to call with the deserialized arguments to the method; the return value will be serialized to JSON-RPC and sent back to the caller
text: the human-readable name of the method
help: help text for the method
logopt: (optional - by convention) log options which can be used by a custom logger (see the getLogMessage parameter)
cmark: (optional) a data structure to be added to the context argument when the request method is called
|
| getLogMessage | an optional closure or call reference to be called when an incoming request is received; if this is set then it will be called with the following arguments: a context hash (see HttpServer::AbstractHttpRequestHandler::handleRequest() for a description of the context hash), the method definition as passed in the methods argument to this constructor, and a reference to the arguments in this call |
| dbg | this parameter is set to True, then additional information will be logged when errors occur |
| get_prefix | prefix to add to derived methods with GET requests if no "." characters are in the path |
- Exceptions
-
| JSON-RPC-CONSTRUCTOR-ERROR | missing "name", "function", or "text" key in method hash,
\c "function" key not assigned to a callable value |
◆ hasMethod()
| bool JsonRpcHandler::JsonRpcHandler::hasMethod |
( |
string |
text | ) |
|
Check if a method exists.
- Parameters
-
| text | the text name of the method |
- Returns
- True if the method exists
The documentation for this class was generated from the following file:
- doxygen/qlib/JsonRpcHandler/JsonRpcHandler.qm.dox.h