216 |
217 | proc enableRequestLogger() {...}{.raises: [Exception, IOError],
218 | tags: [RootEffect, ReadDirEffect].}
219 | -
220 |
221 | Start to log all requests with content, even passwords, into file "requests.log". The file can be used for automated tests, to archive and replay all actions.
222 |
223 |
224 |
225 | proc disableRequestLogger() {...}{.raises: [], tags: [].}
226 | -
227 |
228 | Will stop to log to "requests.log" (default)
229 |
230 |
231 |
232 | proc addRequest(request: string;
233 | callback: proc (value: string): string {...}{.gcsafe.}) {...}{.
234 | raises: [Exception], tags: [RootEffect].}
235 | -
236 |
237 | This will register a function "callback" that can run on back-end. "addRequest" will be performed with "value" each time the javascript client calls: window.ui.backend(request, value, function(response) {...}) with the specific "request" value. There is a wrapper for python, C and C++ to handle strings in each specific programming language
238 |
239 |
240 |
241 | proc dispatchRequest(request: string; value: string): string {...}{.
242 | raises: [Exception, ReqUnknownException], tags: [RootEffect].}
243 | -
244 |
245 | Global string dispatcher that will trigger a previously registered functions
246 |
247 |
248 |
249 | proc dispatchJsonRequest(jsonMessage: JsonNode): string {...}{.
250 | raises: [KeyError, Exception, ReqUnknownException], tags: [RootEffect].}
251 | -
252 |
253 | Global json dispatcher that will be called from webview AND jester This will extract specific values that were prepared by backend-helper.js and forward those values to the string dispatcher.
254 |
255 |
256 |
257 | proc dispatchCommandLineArg(escapedArgv: string): string {...}{.raises: [Exception],
258 | tags: [ReadIOEffect, WriteIOEffect, RootEffect].}
259 | -
260 |
261 | Will handle previously logged request json and forward those to registered functions.
262 |
263 |
264 |
265 | proc readAndParseJsonCmdFile(filename: string) {...}{.raises: [Exception, IOError],
266 | tags: [ReadDirEffect, RootEffect, ReadIOEffect, WriteIOEffect].}
267 | -
268 |
269 | Will open, parse a file of previously logged requests and re-runs those requests.
270 |
271 |
272 |
273 | proc dispatchHttpRequest(jsonMessage: JsonNode; headers: HttpHeaders): string {...}{.
274 | raises: [KeyError, Exception, ReqUnknownException], tags: [RootEffect].}
275 | -
276 |
277 | Modify this, if you want to add some authentication, input format validation or if you want to process HttpHeaders.
278 |
279 |
280 |
281 | proc startHttpServer(indexHtmlFile: string; port: int = 8000;
282 | bindAddr: string = "localhost") {...}{.
283 | raises: [Exception, OSError, IOError, ValueError],
284 | tags: [ReadIOEffect, RootEffect, ReadDirEffect, WriteIOEffect, TimeEffect].}
285 | -
286 |
287 | Start Http server (Jester) in blocking mode. indexHtmlFile will displayed for "/". Files in parent folder or sub folders may be accessed without further check. Will run forever.
288 |
289 |
290 |
291 | proc stopDesktop() {...}{.raises: [Exception], tags: [RootEffect].}
292 | -
293 |
294 | Will stop the Http server - may trigger application exit.
295 |
296 |
297 |
298 | proc startDesktop(indexHtmlFile: string; title: string = "nimview";
299 | width: int = 640; height: int = 480; resizable: bool = true;
300 | debug: bool = defined release) {...}{.raises: [Exception, OSError,
301 | IOError, KeyError, ValueError, JsonParsingError, ReqUnknownException],
302 | tags: [ReadIOEffect, RootEffect, ReadDirEffect, WriteIOEffect].}
303 | -
304 |
305 | Will start Webview Desktop UI to display the index.hmtl file in blocking mode.
306 |
307 |
308 |
309 | proc start(indexHtmlFile: string; port: int = 8000;
310 | bindAddr: string = "localhost"; title: string = "nimview";
311 | width: int = 640; height: int = 480; resizable: bool = true) {...}{.raises: [
312 | Exception, OSError, IOError, ValueError, KeyError, JsonParsingError,
313 | ReqUnknownException],
314 | tags: [ReadIOEffect, RootEffect, ReadDirEffect, WriteIOEffect, TimeEffect].}
315 | -
316 |
317 | Tries to automatically select the Http server in debug mode or when no UI available and the Webview Desktop App in Release mode, if UI available. Notice that this may take the debug mode information of the dll at dll compile timenim.
318 |
319 |
320 |
321 |