Qore RestHandler Module Reference  1.1
 All Classes Namespaces Functions Variables Groups Pages
RestHandler.qm.dox.h
1 // -*- mode: c++; indent-tabs-mode: nil -*-
3 
25 // minimum qore version
26 
27 // require type definitions everywhere
28 
29 // enable all warnings
30 
31 
32 
33 
34 
35 
308 namespace RestHandler {
312 
313 public:
314 private:
315 
316 public:
317 
318  private :
321 
324 
325 public:
326 
328 
342 
343 
345 
355 
356  };
357 
360 
361 public:
362  private :
364  bool deserialized;
365 
366 public:
367 
369  constructor(RestHandler::AbstractRestStreamRequestHandler rsh, HttpListener listener, AbstractHttpRequestHandler handler, Socket s, hash cx, hash hdr, any body);
370 
371 
372  // callback method for the response header; this calls @ref RestHandler::AbstractRestStreamRequestHandler::getResponseHeaderMessage() and returns the result
383 
384 
386 
396  private nothing recvImpl(hash v);
397 
398 
400 
403  private any sendImpl();
404 
405  };
406 
409 
410 public:
411 private:
412 
413 public:
414 
415  constructor();
416 
417 
419  abstract string name();
420 
422 
438  *AbstractRestClass subClass(string name, hash cx, *hash args);
439 
440 
442  hash handleRequest(HttpListener listener, RestHandler rh, Socket s, *list cl, string mn, hash cx, *hash args);
443 
444 
446  private hash dispatchStream(HttpListener listener, RestHandler rh, Socket s, string mn, *hash ah, hash cx);
447 
448 
450  private hash dispatch(RestHandler rh, string mn, *hash ah, hash cx);
451 
452 
454  private hash unknownSubClassError(string name);
455 
456  };
457 
459 
470 
471 public:
472  public :
474  const Err501 = (
475  "code": 501,
476  "body": "not implemented",
477  );
478 
480  const Methods = (
481  "GET": "get",
482  "POST": "post",
483  "PUT": "put",
484  "DELETE": "del",
485  "OPTIONS": "options",
486  );
487 
489  const MimeDataTypes = (
490  MimeTypeJsonRpc: (
491  "serialize": \makeJSONString(),
492  "deserialize": \parseJSON(),
493  ),
494  MimeTypeYaml: (
495  "serialize": \makeYAML(),
496  "deserialize": \parseYAML(),
497  ),
498 
499  MimeTypeYamlRpc: (
500  "serialize": \makeYAML(),
501  "deserialize": \parseYAML(),
502  ),
503  MimeTypeXml: (
504  "serialize": \makeXMLRPCValueString(),
505  "deserialize": \parseXMLRPCValue(),
506  ),
507  MimeTypeHtml: (
508  "serialize": string (any $body) { return sprintf("<pre>%N</pre>", $body); },
509  ),
510  );
511 
512 public:
513 
514  private :
517 
519  Mutex mx();
520 
521 public:
522 
524 
526  constructor(*AbstractAuthenticator auth);
527 
528 
530  string name();
531 
532 
534 
556  hash handleRequest(HttpListener listener, Socket s, hash cx, hash hdr, *data b);
557 
558 
560  removeRootPath(reference path);
561 
562 
564  requestDeserializationError(hash hdr, hash cx, string body);
565 
566 
568  responseSerializationError(hash cx, *hash aih, hash rv);
569 
570 
572  logInfo(string fmt);
573 
574 
576  logError(string fmt);
577 
578 
580  logDebug(string fmt);
581 
582 
584  addClass(AbstractRestClass cls);
585 
586 
588  static hash makeResponse(int code, any body, *hash hdr);
589  };
590 };
string sprintf(string fmt,...)
hash ch
class hash: name -> AbstractRestClass
Definition: RestHandler.qm.dox.h:516
constructor(hash cx, *hash ah)
creates the object with the given arguments
const MimeTypeYaml
const MimeTypeXml
AbstractHttpRequestHandler handler
const MimeTypeJsonRpc
list list(...)
const MimeTypeYamlRpc
private nothing recvImpl(hash v)
callback method for receiving chunked data; this calls RestHandler::AbstractRestStreamRequestHandler:...
hash handleRequest(HttpListener listener, RestHandler rh, Socket s, *list cl, string mn, hash cx, *hash args)
this method is called by the RestHandler class to match the right object with incoming requests ...
*AbstractRestClass subClass(string name, hash cx, *hash args)
this method will be called to find a sub-class (ie with GET /invoices/1 - if this class represents "...
the base abstract class for REST stream request handlers
Definition: RestHandler.qm.dox.h:311
the base abstract class for REST handler classes
Definition: RestHandler.qm.dox.h:408
private hash getResponseHeaderMessageImpl()
the base class for handling HTTP chunked requests and responses within the RestHandler infrastructure...
Definition: RestHandler.qm.dox.h:359
hash getResponseHeaderMessage()
this method returns the response message description hash by calling getResponseHeaderMessageImpl() ...
private any sendImpl()
callback method for sending chunked data; this calls RestHandler::AbstractRestStreamRequestHandler::s...
abstract string name()
this provides the name of the REST class
private hash dispatchStream(HttpListener listener, RestHandler rh, Socket s, string mn, *hash ah, hash cx)
this method is called to dispatch streamed requests on the given object
private hash unknownSubClassError(string name)
throws a "REST-CLASS-ERROR" exception when a request tries to access an unknown subclass ...
private hash dispatch(RestHandler rh, string mn, *hash ah, hash cx)
this method is called to dispatch requests on the given object
const MimeTypeHtml
hash hash(object obj)
hash rhdr
headers to add in the response
Definition: RestHandler.qm.dox.h:323
this is the main handler class to be registered with the HttpServer
Definition: RestHandler.qm.dox.h:469
constructor(RestHandler::AbstractRestStreamRequestHandler rsh, HttpListener listener, AbstractHttpRequestHandler handler, Socket s, hash cx, hash hdr, any body)
creates the object with the given attributes
hash ah
call argument hash
Definition: RestHandler.qm.dox.h:320