Introduction
This module implements server-side support for a proprietary RPC-based protocol using YAML for serialization/deserialization of message data.
This module provides the YamlRpcHandler class which can be used to provide an RPC handler for the HttpServer class provided by the HttpServer module.
See the YamlRpcClient module for a description of the YAML-RPC protocol implemented here.
Example Usage
%new-style
%strict-args
%require-types
%enable-all-warnings
%requires HttpServer
%requires YamlRpcHandler
%requires Mime
const ApiMethods = (
{
"name": "^sys\\.shutdown\$",
"text": "sys.shutdown",
"function": sub () { background http.stop(); return "OK"; },
"help": "shuts down this server",
"logopt": 0,
},
);
code log = sub (string str) {printf("%y: %s\n", now_us(), str);};
const Bind = 8888;
YamlRpcHandler yamlRpcHandler(new AbstractAuthenticator(), api);
our HttpServer http(log, log);
http.addListener(Bind);
http.setHandler("yamlrpc", "", MimeTypeYamlRpc, yamlRpcHandler);
http.setDefaultHandler("yamlrpc", yamlRpcHandler);
log("now listening on %s\n", Bind);
http.waitStop();
YamlRpcHandler Release Notes
YamlRpcHandler v1.2
- fixed a bug where serialization errors would result in confusing responses (issue 4194)
- minor error logging updates
- updated minimum qore version to 0.8.12 for get_ex_pos()
- updated for new YAML function names (removed references to deprecated camel-case functions)
YamlRpcHAndler v1.1
added optional log closure to constructor
YamlRpcHAndler v1.0