Qore XmlRpcHandler Module Reference: docs/qlib/XmlRpcHandler.qm.dox.h Source File

Qore XmlRpcHandler Module Reference 1.0

- Main Page
- Namespaces
- Classes

All Classes Namespaces Functions Variables Pages
XmlRpcHandler.qm.dox.h
1 // -*- mode: c++; indent-tabs-mode: nil -*-
3
4 /* XmlRpcHandler.qm Copyright 2012 - 2013 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 HttpServer definitions
32
33
34 /* Version History
35 * 2012-05-31 v1.0: David Nichols <david@qore.org>: updated to a user module
36 * 2013-09-24 v1.1: David Nichols <david@qore.org>: added optional log closure to constructor
37 */
38
78 namespace XmlRpcHandler {
81
83 class XmlRpcHandler : public AbstractHttpRequestHandler {
84
85 public:
87 const Version = "1.0";
88
90 const InternalMethods = (
91 ("function": "help",
92 "help": "shows a list of XML-RPC methods registered with this handler",
93 "text": "help",
94 "logopt": 2,
95 ),
96 ("function": "listMethods",
97 "help": "lists XML-RPC method names registered with this handler",
98 "text": "system.listMethods",
99 "logopt": 2,
100 ),
101 );
102
104 const XMLRPC_INVALID_XML = 2001;
105
107 private :
108 list methods = ();
109 hash mi = hash();
110 int loglevel;
111
112 // if True then verbose exception info will be logged
113 bool debug;
114
115 // prefix to add to derived methods with GET requests if no "." characters are in the path
116 *string get_prefix;
117
118 // a closure/call reference to get the log message and/or process arguments in incoming requests
119 *code getLogMessage;
120
121 // a closure/call reference for logging (when set this is used instead of the HTTP server's logfunc for logging)
122 *code log;
123
124 public:
126
128
145 constructor(AbstractAuthenticator auth, list methods, *code getLogMessage, bool dbg = False, *string get_prefix, *code log);
146
147
149
156 addMethod(string name, code func, string text, string help, int logopt, any cmark);
157
158
160 setDebug(bool dbg = True);
161
162
164 bool getDebug();
165
166
168 // don't reimplement this method; fix/enhance it in the module
169
170 private:
171 final addMethodInternal(hash h);
172 public:
173
174
175
176 private:
177 hash help();
178 public:
179
180
181
182 private:
183 list listMethods();
184 public:
185
186
187
188 private:
189 log(hash cx, string str);
190 public:
191
192
193 // don't reimplement this method; fix/enhance it in the module
194
195 private:
196 final hash callMethod(hash cx, any params);
197 public:
198
199
200 // method called by HttpServer to handle an XML-RPC request
201 // don't reimplement this method; fix/enhance it in the module
202 final hash handleRequest(hash cx, hash hdr, *data body);
203
205 };
206 };
XmlRpcHandler::XmlRpcHandler::getDebug
bool getDebug()
returns the current status of the debug flag
XmlRpcHandler::XmlRpcHandler::constructor
constructor(AbstractAuthenticator auth, list methods, *code getLogMessage, bool dbg=False, *string get_prefix, *code log)
creates the handler with the given method list
XmlRpcHandler::XmlRpcHandler::InternalMethods
const InternalMethods
internal methods (for introspection)
Definition: XmlRpcHandler.qm.dox.h:90
XmlRpcHandler::XmlRpcHandler::Version
const Version
version of the implementation
Definition: XmlRpcHandler.qm.dox.h:87
XmlRpcHandler::XmlRpcHandler::setDebug
setDebug(bool dbg=True)
turns on or off debugging; when debugging is enabled more verbose error messages are reported ...
XmlRpcHandler::XmlRpcHandler::addMethod
addMethod(string name, code func, string text, string help, int logopt, any cmark)
adds a method to the handler dynamically
XmlRpcHandler::XmlRpcHandler
XML-RPC Handler implementation; to be registered as a request handler in the HttpServer class...
Definition: XmlRpcHandler.qm.dox.h:83
XmlRpcHandler::XmlRpcHandler::XMLRPC_INVALID_XML
const XMLRPC_INVALID_XML
error code for invalid XML-RPC
Definition: XmlRpcHandler.qm.dox.h:104