Qore YamlRpcHandler Module Reference  1.2
 All Classes Namespaces Functions Variables Pages
YamlRpcHandler::YamlRpcHandler Class Reference

YamlRpcHandler class definition; to be registered as a handler in the HttpServer class. More...

Inherits AbstractHttpRequestHandler.

Public Member Functions

 constructor (HttpServer::AbstractAuthenticator v_auth, list v_methods, *code v_get_log_msg, bool v_dbg=False, *string v_get_prefix, *code v_log)
 creates the handler with the given method list More...
 
 addMethod (string name, code func, string text, string help, auto logopt, auto cmark)
 adds a method to the handler dynamically More...
 
 setDebug (bool dbg=True)
 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
 

Static Public Member Functions

static string makeResponse (auto response, int flags=YAML::None)
 serializes a reponse in YAML-RPC format given the arguments
 
static string makeErrorResponse (int code, string mess, auto err, int flags=YAML::None)
 serializes an error reponse in YAML-RPC format given the arguments
 

Public Attributes

const Version = "1.0"
 implementation of the handler
 
const InternalMethods
 internal methods of the handler (introspection)
 

Detailed Description

YamlRpcHandler class definition; to be registered as a handler in the HttpServer class.

Member Function Documentation

YamlRpcHandler::YamlRpcHandler::addMethod ( string  name,
code  func,
string  text,
string  help,
auto  logopt,
auto  cmark 
)

adds a method to the handler dynamically

Parameters
namea regular expression to use for matching the method name
funca 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 YAML-RPC and sent back to the caller
textthe human-readable name of the method
helphelp text for the method
logoptlog options which can be used by a custom logger (see the getLogMessage parameter)
cmarkany value that will be added in the method hash under the "cmark" key
YamlRpcHandler::YamlRpcHandler::constructor ( HttpServer::AbstractAuthenticator  v_auth,
list  v_methods,
*code  v_get_log_msg,
bool  v_dbg = False,
*string  v_get_prefix,
*code  v_log 
)

creates the handler with the given method list

Parameters
v_authan authentication object (use new AbstractAuthenticator() for no authentication)
v_methodsa 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 YAML-RPC and sent back to the caller
  • help: help text for the method
  • text: the human-readable name of the method
  • logopt: (optional - by convention) log options which can be used by a custom logger (see the getLogMessage parameter)
v_get_log_msgan 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
v_dbgthis parameter is set to True, then additional information will be logged when errors occur
v_get_prefixprefix to add to derived methods with GET requests if no "." characters are in the path
v_logan optional closure or call reference to be called when logging
Exceptions
YAML-RPC-CONSTRUCTOR-ERRORmissing "name", "function", or "text" key in method hash, \c "function" key not assigned to a callable value