Qore XmlRpcHandler Module Reference  1.1
XmlRpcHandler.qm.dox.h
1 // -*- mode: c++; indent-tabs-mode: nil -*-
3 
4 /* XmlRpcHandler.qm Copyright (C) 2012 - 2014 David Nichols
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  __7_ string get_prefix;
121 
122  // a closure/call reference to get the log message and/or process arguments in incoming requests
123  __7_ 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  __7_ code logc;
127 
128 public:
130 
132 
149  constructor(HttpServer::AbstractAuthenticator auth, list methods, __7_ code n_getLogMessage, bool dbg = False, __7_ string n_get_prefix, __7_ code log);
150 
151 
153 
160  addMethod(string name, code func, string text, string help, int logopt, any cmark);
161 
162 
164  setDebug(bool dbg = True);
165 
166 
168  bool getDebug();
169 
170 
172  // don't reimplement this method; fix/enhance it in the module
173  final private addMethodInternal(hash h);
174 
175 
176  private hash help();
177 
178 
179  private list listMethods();
180 
181 
182  private log(hash cx, string str);
183 
184 
185  // don't reimplement this method; fix/enhance it in the module
186  final private hash callMethod(hash cx, any params);
187 
188 
189  // method called by HttpServer to handle an XML-RPC request
190  // don't reimplement this method; fix/enhance it in the module
191  final hash handleRequest(hash cx, hash hdr, __7_ data body);
192 
194  };
195 };
the XmlRpcHandler namespace holds all public definitions in the XmlRpcHandler module ...
Definition: XmlRpcHandler.qm.dox.h:83