the RestHandler namespace contains all the objects in the RestHandler module
More...
the RestHandler namespace contains all the objects in the RestHandler module
RestHandler::constructor |
( |
*AbstractAuthenticator |
auth | ) |
|
create the object optionally with the given AbstractAuthenticator
- Parameters
-
auth | the authentication object to use to authenticate connections (see AbstractAuthenticator); if no AbstractAuthenticator object is passed, then by default no authentication will be required |
hash RestHandler::handleRequest |
( |
hash |
cx, |
|
|
hash |
hdr, |
|
|
*data |
b |
|
) |
| |
called by the HTTP server to handle incoming HTTP requests
Requests will be dispatched to REST classes registered with this object
- Parameters
-
cx | call 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 parseURL())
id: the unique HTTP connection ID
listener-id : the HTTP server listener ID (see HttpServer::getListenerInfo())
user: the current RBAC username (if any)
|
hdr | incoming header hash; all keys will be converted to lower-case, additionally the following keys will be present:
method: the HTTP method received (ie "GET" , "POST" , etc)
path: the HTTP path given in the request, after processing by decode_url() (Qore function)
http_version: the HTTP version number in the request (either "1.0" or "1.1" )
|
b | message body, if any |
- Returns
- a hash with the following keys:
"code"
: the HTTP return code (see HttpServer::HttpCodes)
"body"
: the message body to return in the response
"close"
: (optional) set this key to True if the connection should be unconditionally closed when the handler returns
"hdr"
: (optional) set this key to a hash of extra header information to be returned with the response