316 namespace RestHandler {
519 abstract string name();
576 "body":
"not implemented",
585 "OPTIONS":
"options",
591 "serialize": \make_json(),
592 "deserialize": \parse_json(),
595 "serialize": \make_yaml(),
596 "deserialize": \parse_yaml(),
600 "serialize": \make_yaml(),
601 "deserialize": \parse_yaml(),
604 "serialize": \make_xmlrpc_value(),
605 "deserialize": \parse_xmlrpc_value(),
608 "serialize":
string (any body) {
return sprintf(
"<pre>%N</pre>", body); },
logError(string fmt)
default implementation is empty; this method is called with error log messages; reimplement in subcla...
string sprintf(string fmt,...)
const Err501
a hash for a 501 Unimplemented error message
Definition: RestHandler.qm.dox.h:574
hash ch
class hash: name -> AbstractRestClass
Definition: RestHandler.qm.dox.h:616
*int getTimeout()
returns the timeout in milliseconds or NOTHING if no timeout is set
string name()
returns the name of the root REST class
*AbstractAuthenticator auth
streamError(hash n_ex)
registers stream errors in the send operation with the stream handler if no error is already present ...
hash cx
call context hash
Definition: RestHandler.qm.dox.h:335
static hash makeResponse(int code, any body, *hash hdr)
creates a hash for an HTTP response with the response code and a literal response message body ...
logDebug(string fmt)
default implementation is empty; this method is called with debug log messages; reimplement in subcla...
AbstractHttpRequestHandler handler
destructor()
destroys the object and updates the request handler about the status of the persistent connection ...
constructor(*HttpServer::AbstractAuthenticator auth)
create the object optionally with the given HttpServer::AbstractAuthenticator
const MimeDataTypes
supported mime types for de/serializing responses
Definition: RestHandler.qm.dox.h:589
abstract any sendImpl()
abstract callback method for sending chunked data
removeRootPath(reference path)
default implementation is empty
requestDeserializationError(hash hdr, hash cx, string body)
default implementation is empty
responseSerializationError(hash cx, *hash aih, hash rv)
default implementation is empty
addClass(AbstractRestClass cls)
adds a REST class to the handler
logInfo(string fmt)
default implementation is empty; this method is called with informational log messages; reimplement i...
private nothing recvImpl(hash v)
callback method for receiving chunked data; this calls RestHandler::AbstractRestStreamRequestHandler:...
nothing recv(hash v)
this method provides the callback method for receiving chunked data by calling recvImpl() ...
*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 "...
*hash ah
call argument hash
Definition: RestHandler.qm.dox.h:341
the base abstract class for REST stream request handlers
Definition: RestHandler.qm.dox.h:326
HttpListenerInterface listener
constructor(RestHandler::AbstractRestStreamRequestHandler n_stream, HttpServer::HttpListenerInterface listener, HttpServer::AbstractHttpRequestHandler handler, Socket s, hash cx, hash hdr, any body)
creates the object with the given attributes
hash handleRequest(HttpListenerInterface listener, Socket s, hash cx, hash hdr, *data b)
called by the HTTP server to handle incoming HTTP requests
the base abstract class for REST handler classes
Definition: RestHandler.qm.dox.h:508
private hash getResponseHeaderMessageImpl()
const Methods
supported HTTP methods
Definition: RestHandler.qm.dox.h:580
the base class for handling HTTP chunked requests and responses within the RestHandler infrastructure...
Definition: RestHandler.qm.dox.h:455
*int timeout_ms
socket I/O timeout in milliseconds
Definition: RestHandler.qm.dox.h:347
hash getResponseHeaderMessage()
this method returns the response message description hash by calling getResponseHeaderMessageImpl() ...
*code getPersistentClosedNotification()
returns a callable value in case a persistent connection is in progress; NOTHING if not; this method ...
private any sendImpl()
callback method for sending chunked data; this calls RestHandler::AbstractRestStreamRequestHandler::s...
private hash dispatchStream(HttpListenerInterface listener, RestHandler rh, Socket s, string mn, *hash ah, hash cx)
this method is called to dispatch streamed requests on the given object
bool isPersistent()
returns True if the connection is persistent; this method in the base class returns False by default ...
private hash unknownSubClassError(string n_name)
throws a "REST-CLASS-ERROR" exception when a request tries to access an unknown subclass ...
abstract string name()
this provides the name of the REST class
abstract hash getResponseHeaderMessageImpl()
this method should return the response message description hash
private hash dispatch(RestHandler rh, string mn, *hash ah, hash cx)
this method is called to dispatch requests on the given object
*hash ex
if an exception is raised in a callback then the exception hash is saved here
Definition: RestHandler.qm.dox.h:338
hash rhdr
headers to add in the response
Definition: RestHandler.qm.dox.h:344
abstract nothing recvImpl(hash v)
abstract callback method for receiving chunked data
this is the main handler class to be registered with the HttpServer
Definition: RestHandler.qm.dox.h:569
any send()
this method provides the callback method for sending chunked data by calling sendImpl() ...
constructor(hash n_cx, *hash n_ah)
creates the object with the given arguments
hash handleRequest(HttpListenerInterface 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 ...
setTimeout(timeout n_timeout_ms)
sets the internal socket I/O timeout value in ms