Qore YamlRpcHandler Module Reference  1.2
 All Classes Namespaces Functions Variables Pages

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

1 %new-style
2 %strict-args
3 %require-types
4 %enable-all-warnings
5 
6 %requires HttpServer
7 %requires YamlRpcHandler
8 %requires Mime
9 
10 const ApiMethods = (
11  ("name": "^sys\\.shutdown\$",
12  "text": "sys.shutdown",
13  "function": sub () { background http.stop(); return "OK"; },
14  "help": "shuts down this server",
15  "logopt": 0,
16  ),
17 );
18 
19 # a logging closure
20 code log = sub (string str) {printf("%y: %s\n", now_us(), str);};
21 
22 # our bind address
23 const Bind = 8888;
24 
25 YamlRpcHandler yamlRpcHandler(new AbstractAuthenticator(), api);
26 our HttpServer http(log, log);
27 http.addListener(Bind);
28 http.setHandler("yamlrpc", "", MimeTypeYamlRpc, yamlRpcHandler);
29 http.setDefaultHandler("yamlrpc", yamlRpcHandler);
30 log("now listening on %s\n", Bind);
31 http.waitStop();

YamlRpcHandler Release Notes

YamlRpcHandler v1.2

  • 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

  • updated to a user module