Qore RestHandler Module Reference: doxygen/qlib/RestHandler.qm.dox.h Source File

Qore RestHandler Module Reference 1.1

- Main Page
- Related Pages
- Namespaces
- Classes

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 {
311 class AbstractRestStreamRequestHandler : public HttpServer::AbstractStreamRequestHandler {
312
313 public:
314 private:
315
316 public:
317
318 private :
320 hash ah;
321
323 hash rhdr;
324
325 public:
326
328
341 constructor(hash cx, *hash ah);
342
343
345
354 hash getResponseHeaderMessage();
355
356 };
357
359 class RestStreamRequest : public HttpServer::AbstractStreamRequest {
360
361 public:
362 private :
363 RestHandler::AbstractRestStreamRequestHandler rsh;
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
382 private hash getResponseHeaderMessageImpl();
383
384
386
396 private nothing recvImpl(hash v);
397
398
400
403 private any sendImpl();
404
405 };
406
408 class AbstractRestClass {
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
469 class RestHandler : public HttpServer::AbstractHttpRequestHandler,public AbstractRestClass {
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 :
516 hash ch;
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 };
sprintf
string sprintf(string fmt,...)
HttpServer::AbstractStreamRequest::hdr
hash hdr
RestHandler::RestHandler::ch
hash ch
class hash: name -> AbstractRestClass
Definition: RestHandler.qm.dox.h:516
HttpServer::AbstractStreamRequest
HttpServer::AbstractHttpRequestHandler
RestHandler::AbstractRestStreamRequestHandler::constructor
constructor(hash cx, *hash ah)
creates the object with the given arguments
MimeTypeYaml
const MimeTypeYaml
MimeTypeXml
const MimeTypeXml
HttpServer::AbstractStreamRequest::handler
AbstractHttpRequestHandler handler
HttpServer::AbstractStreamRequestHandler::cx
hash cx
MimeTypeJsonRpc
const MimeTypeJsonRpc
HttpServer::AbstractStreamRequestHandler
list
list list(...)
HttpServer::AbstractStreamRequest::cx
hash cx
HttpServer::AbstractStreamRequest::s
Socket s
MimeTypeYamlRpc
const MimeTypeYamlRpc
RestHandler::RestStreamRequest::recvImpl
private nothing recvImpl(hash v)
callback method for receiving chunked data; this calls RestHandler::AbstractRestStreamRequestHandler:...
RestHandler::AbstractRestClass::handleRequest
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 ...
RestHandler::AbstractRestClass::subClass
*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 "...
RestHandler::AbstractRestStreamRequestHandler
the base abstract class for REST stream request handlers
Definition: RestHandler.qm.dox.h:311
RestHandler::AbstractRestClass
the base abstract class for REST handler classes
Definition: RestHandler.qm.dox.h:408
RestHandler::RestStreamRequest::getResponseHeaderMessageImpl
private hash getResponseHeaderMessageImpl()
RestHandler::RestStreamRequest
the base class for handling HTTP chunked requests and responses within the RestHandler infrastructure...
Definition: RestHandler.qm.dox.h:359
RestHandler::AbstractRestStreamRequestHandler::getResponseHeaderMessage
hash getResponseHeaderMessage()
this method returns the response message description hash by calling getResponseHeaderMessageImpl() ...
RestHandler::RestStreamRequest::sendImpl
private any sendImpl()
callback method for sending chunked data; this calls RestHandler::AbstractRestStreamRequestHandler::s...
RestHandler::AbstractRestClass::name
abstract string name()
this provides the name of the REST class
HttpServer::AbstractStreamRequest::listener
HttpListener listener
RestHandler::AbstractRestClass::dispatchStream
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
RestHandler::AbstractRestClass::unknownSubClassError
private hash unknownSubClassError(string name)
throws a "REST-CLASS-ERROR" exception when a request tries to access an unknown subclass ...
RestHandler::AbstractRestClass::dispatch
private hash dispatch(RestHandler rh, string mn, *hash ah, hash cx)
this method is called to dispatch requests on the given object
MimeTypeHtml
const MimeTypeHtml
hash
hash hash(object obj)
RestHandler::AbstractRestStreamRequestHandler::rhdr
hash rhdr
headers to add in the response
Definition: RestHandler.qm.dox.h:323
RestHandler::RestHandler
this is the main handler class to be registered with the HttpServer
Definition: RestHandler.qm.dox.h:469
RestHandler::RestStreamRequest::constructor
constructor(RestHandler::AbstractRestStreamRequestHandler rsh, HttpListener listener, AbstractHttpRequestHandler handler, Socket s, hash cx, hash hdr, any body)
creates the object with the given attributes
HttpServer::AbstractStreamRequest::body
any body
RestHandler::AbstractRestStreamRequestHandler::ah
hash ah
call argument hash
Definition: RestHandler.qm.dox.h:320