Qore XmlRpcHandler Module Reference  1.1
XmlRpcHandler.qm.dox.h
1 // -*- mode: c++; indent-tabs-mode: nil -*-
3 
4 /* XmlRpcHandler.qm Copyright (C) 2012 - 2018 Qore Technologies, s.r.o.
5 
6  Permission is hereby granted, free of charge, to any person obtaining a
7  copy of this software and associated documentation files (the "Software"),
8  to deal in the Software without restriction, including without limitation
9  the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  and/or sell copies of the Software, and to permit persons to whom the
11  Software is furnished to do so, subject to the following conditions:
12 
13  The above copyright notice and this permission notice shall be included in
14  all copies or substantial portions of the Software.
15 
16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  DEALINGS IN THE SOFTWARE.
23 */
24 
25 // minimum qore version
26 
27 // requires the binary xml module
28 
29 // need mime definitions
30 
31 // need the Util module
32 
33 // need HttpServerUtil definitions
34 
35 // do not use $ for vars
36 
37 
38 /* Version History
39  * 2012-05-31 v1.0: David Nichols <david@qore.org>: updated to a user module
40  * 2013-09-24 v1.1: David Nichols <david@qore.org>: added optional log closure to constructor
41 */
42 
82 namespace XmlRpcHandler {
85 
87 class XmlRpcHandler : public AbstractHttpRequestHandler {
88 
89 public:
91  const Version = "1.0";
92 
94  const InternalMethods = (
95  ("function": "help",
96  "help": "shows a list of XML-RPC methods registered with this handler",
97  "text": "help",
98  "logopt": 2,
99  ),
100  ("function": "listMethods",
101  "help": "lists XML-RPC method names registered with this handler",
102  "text": "system.listMethods",
103  "logopt": 2,
104  ),
105  );
106 
108  const XMLRPC_INVALID_XML = 2001;
109 
111  private :
112  list methods = ();
113  hash mi = hash();
114  int loglevel;
115 
116  // if True then verbose exception info will be logged
117  bool debug;
118 
119  // prefix to add to derived methods with GET requests if no "." characters are in the path
120  *string get_prefix;
121 
122  // a closure/call reference to get the log message and/or process arguments in incoming requests
123  *code getLogMessage;
124 
125  // a closure/call reference for logging (when set this is used instead of the HTTP server's logfunc for logging)
126  *code logc;
127 
128 public:
130 
132 
148  constructor(HttpServer::AbstractAuthenticator auth, list methods, *code n_getLogMessage, bool dbg = False, *string n_get_prefix, *code log) ;
149 
150 
152 
159  addMethod(string name, code func, string text, string help, int logopt, auto cmark);
160 
161 
163  setDebug(bool dbg = True);
164 
165 
167  bool getDebug();
168 
169 
171  // don't reimplement this method; fix/enhance it in the module
172 
173 private:
174  final addMethodInternal(hash h);
175 public:
176 
177 
178 
179 private:
180  hash help();
181 public:
182 
183 
184 
185 private:
186  list listMethods();
187 public:
188 
189 
190 
191 private:
192  log(hash cx, string str);
193 public:
194 
195 
196  // don't reimplement this method; fix/enhance it in the module
197 
198 private:
199  final hash callMethod(hash cx, auto params);
200 public:
201 
202 
203  // method called by HttpServer to handle an XML-RPC request
204  // don't reimplement this method; fix/enhance it in the module
205  final hash handleRequest(hash cx, hash hdr, *data body);
206 
208  };
209 };
the XmlRpcHandler namespace holds all public definitions in the XmlRpcHandler module ...
Definition: XmlRpcHandler.qm.dox.h:83