Qore RestHandler Module Reference  1.3.1
RestHandler::AbstractRestClass Class Referenceabstract

the base abstract class for REST handler classes More...

Inheritance diagram for RestHandler::AbstractRestClass:

Public Member Methods

 addClass (AbstractRestClass cls)
 adds a REST class to the handler
 
hash< HttpServer::HttpHandlerResponseInfohandleRequest (HttpListenerInterface listener, RestHandler rh, Socket s, *list< string > cl, string mn, hash< auto > cx, *hash< auto > args)
 this method is called by the RestHandler class to match the right object with incoming requests
 
abstract string name ()
 this provides the name of the REST class
 

Public Attributes

hash< string, AbstractRestClassclass_hash
 class hash: name -> AbstractRestClass
 
const RestBasicMethodSet = map {$1: True}
 set of REST class method names based on basic HTTP methods
 

Private Member Methods

hash< HttpServer::HttpHandlerResponseInfodispatch (RestHandler rh, string mn, *hash< auto > ah, hash< auto > cx)
 this method is called to dispatch requests on the given object More...
 
hash< HttpServer::HttpHandlerResponseInfodispatchStream (HttpListenerInterface listener, RestHandler rh, Socket s, string mn, *hash< auto > ah, hash< auto > cx)
 this method is called to dispatch streamed requests on the given object
 
*hash< string, bool > getPossibleSubClasses (hash< auto > cx)
 returns a set of possible subclasses for a particular request More...
 
hash< HttpServer::HttpHandlerResponseInfounknownSubClassError (string cls_name, hash< auto > cx)
 returns a 404 Not Found response when a request tries to access an unknown subclass More...
 

Detailed Description

the base abstract class for REST handler classes

Member Function Documentation

◆ dispatch()

hash<HttpServer::HttpHandlerResponseInfo> RestHandler::AbstractRestClass::dispatch ( RestHandler  rh,
string  mn,
*hash< auto >  ah,
hash< auto >  cx 
)
private

this method is called to dispatch requests on the given object

Parameters
rhthe RestHandler object
mnthe method name
ahthe holds URI and / or message body arguments for the REST call; if a request has both URI query arguments and message body arguments, then this value will be a combination of URI query arguments and deserialized message body arguments with URI query arguments taking precedence over the message body arguments
cxcall context hash; this hash will have the following keys:
  • socket: the bind address used to bind the listener ("socket-info" provides more detailed information)
  • socket-info: a hash of socket information for the listening socket (as returned by Qore::Socket::getSocketInfo())
  • peer-info: a hash of socket information for the remote socket (as returned by Qore::Socket::getPeerInfo())
  • url: a hash of broken-down URL information (as returned from parse_url())
  • id: the unique HTTP connection ID
  • ssl: True if the request was encrypted with HTTPS, False if not
  • listener-id: the HTTP server listener ID (see HttpServer::HttpServer::getListenerInfo())
Returns
the return value is the same as the return value for HttpServer::AbstractHttpRequestHandler::handleRequest()

◆ getPossibleSubClasses()

*hash<string, bool> RestHandler::AbstractRestClass::getPossibleSubClasses ( hash< auto >  cx)
private

returns a set of possible subclasses for a particular request

Parameters
cxthe HTTP call context hash
Returns
a set of possible subclasses for the request
Since
RestHandler 1.3

◆ unknownSubClassError()

hash<HttpServer::HttpHandlerResponseInfo> RestHandler::AbstractRestClass::unknownSubClassError ( string  cls_name,
hash< auto >  cx 
)
private

returns a 404 Not Found response when a request tries to access an unknown subclass

Parameters
cls_namethe URI path element that could not be matched to a REST subclass
cxthe HTTP call context hash
Returns
REST response information
Since
RestHandler 1.3 added the cx argument