|
| | constructor (*HttpServer::AbstractAuthenticator auth, RestSchemaValidator::AbstractRestSchemaValidator validator=new NullRestSchemaValidator()) |
| | create the object optionally with the given HttpServer::AbstractAuthenticator
|
| |
| | constructor (Logger::Logger logger, *HttpServer::AbstractAuthenticator auth, RestSchemaValidator::AbstractRestSchemaValidator validator=new NullRestSchemaValidator(logger)) |
| | create the object optionally with the given Logger and authenticator
|
| |
|
private hash< HttpHandlerResponseInfo > | dispatchRequest (HttpListenerInterface listener, Socket s, *list< string > class_list, string method_name, string path, hash< auto > cx, *hash< auto > args) |
| | Dispatches the request and returns the response.
|
| |
|
hash< auto > | get (hash< auto > cx, *hash< auto > ah) |
| | default get handler for the base handler class
|
| |
| auto | handleExternalRequest (string method, string path, *hash< auto > body, hash< auto > cx={}) |
| | processes REST API calls outside the HTTP server
|
| |
| hash< HttpResponseInfo > | handleRequest (HttpListenerInterface listener, Socket s, hash< auto > cx, hash< auto > hdr, *data b) |
| | called by the HTTP server to handle incoming HTTP requests
|
| |
| | logDebug (string fmt) |
| | This method is called with debug log messages.
|
| |
| | logError (string fmt) |
| | This method is called with error log messages.
|
| |
| | logInfo (string fmt) |
| | This method is called with informational log messages.
|
| |
|
string | name () |
| | returns the name of the root REST class
|
| |
|
| removeRootPath (reference< string > path) |
| | default implementation is empty
|
| |
|
| requestDeserializationError (hash< auto > hdr, hash< auto > cx, string body) |
| | default implementation is empty
|
| |
|
| responseSerializationError (hash< auto > cx, *hash< auto > aih, hash< auto > rv) |
| | default implementation is empty
|
| |
|
| setLogger (Logger::Logger logger) |
| | Sets a new logger.
|
| |
Public Member Functions inherited from RestHandler::AbstractRestClass |
|
| addClass (AbstractRestClass cls) |
| | adds a REST class to the handler
|
| |
| private hash< HttpServer::HttpHandlerResponseInfo > | dispatch (RestHandler rh, string mn, *hash< auto > ah, hash< auto > cx) |
| | this method is called to dispatch requests on the given object
|
| |
|
private hash< HttpServer::HttpHandlerResponseInfo > | dispatchStream (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< HttpServer::HttpHandlerResponseInfo > | handleRequest (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
|
| |
| *AbstractRestClass | subClass (string name, hash< auto > cx, *hash< auto > args) |
| | this method will be called to find a sub-class (ie with GET /invoices/1 - if this class represents "invoices", then subClass("1") will be called to return invoice 1; return NOTHING if the object doesn't exist
|
| |
| *AbstractRestClass | subClassImpl (string name, hash< auto > cx, *hash< auto > args) |
| | this method will be called to find a sub-class (ie with GET /invoices/1 - if this class represents "invoices", then subClass("1") will be called to return invoice 1; return NOTHING if the object doesn't exist
|
| |
|
|
static hash< HttpHandlerResponseInfo > | make200 (hash< auto > hdr, string fmt) |
| | creates a hash for an HTTP 200 OK error response with the response message body as a string
|
| |
|
static hash< HttpHandlerResponseInfo > | make200 (string fmt) |
| | creates a hash for an HTTP 200 OK error response with the response message body as a string
|
| |
|
static hash< HttpHandlerResponseInfo > | make400 (hash< auto > hdr, string fmt) |
| | creates a hash for an HTTP 400 error response with the response message body as a string
|
| |
|
static hash< HttpHandlerResponseInfo > | make400 (string fmt) |
| | creates a hash for an HTTP 400 error response with the response message body as a string
|
| |
|
static hash< HttpHandlerResponseInfo > | make500 (hash< auto > hdr, string fmt) |
| | creates a hash for an HTTP 500 error response with the response message body as a string
|
| |
|
static hash< HttpHandlerResponseInfo > | make500 (string fmt) |
| | creates a hash for an HTTP 500 error response with the response message body as a string
|
| |
|
static hash< HttpHandlerResponseInfo > | make501 (hash< auto > hdr, string fmt) |
| | creates a hash for an HTTP 501 error response with the response message body as a string
|
| |
|
static hash< HttpHandlerResponseInfo > | make501 (string fmt) |
| | creates a hash for an HTTP 501 error response with the response message body as a string
|
| |
|
static hash< HttpHandlerResponseInfo > | makeResponse (int code, auto body, *hash< auto > hdr) |
| | creates a hash for an HTTP response with the response code and a literal response message body
|
| |
|
|
| checkExceptionSerializable (reference< hash< ExceptionInfo > > ex) |
| | Recursively ensure that exception arguments are serializable.
|
| |
| *hash< auto > | errorResponseHeaders (hash< auto > cx) |
| | Retrieves headers for an error response.
|
| |
| hash< HttpHandlerResponseInfo > | returnRestException (hash< ExceptionInfo > ex) |
| | method that determines how exceptions handling REST requests are returned
|
| |
Protected Member Functions inherited from RestHandler::AbstractRestClass |
| *hash< string, bool > | doGetPossibleSubClasses (hash< auto > cx, *hash< auto > ah) |
| | returns a set of possible subclasses for a particular request
|
| |
| hash< HttpServer::HttpHandlerResponseInfo > | unknownSubClassError (string cls_name, hash< auto > cx, *hash< auto > ah) |
| | returns a 404 Not Found response when a request tries to access an unknown subclass
|
| |
this is the main handler class to be registered with the HttpServer
The RestHandler class should be subclassed to customize its behavior.
To provide for logging; the following methods can be reimplemented in subclasses:
In order to match REST requests under a root path, reimplement the following method in a subclass: