Qore WebUtil Module Reference
1.0
|
the WebUtil namespace contains all the objects in the WebUtil module More...
Classes | |
class | FileHandler |
this class serves files from the file system based on a root location More... | |
class | FileTemplate |
manages a template resource that may need to be recompiled if the file is updated in the filesystem; used by WebUtil::TemplateFileManager More... | |
class | StaticTemplateManager |
A container for holding static text templates (ie that do not change once created in the template manager) with mixed text and Qore code. More... | |
class | TemplateFileManager |
this class manages templates based on files More... | |
class | TextTemplateBase |
this is the base class for all template Program container classes More... | |
Functions | |
constructor (string file_root, string url_root="/", *hash opt) | |
create the object optionally with the given AbstractAuthenticator More... | |
hash | fileError (hash cx, hash sh) |
this method returns a 400 "Bad Request" error code when a file should be served that's not a regular file More... | |
hash | handleRequest (hash cx, hash hdr, *data body) |
this method calls handleRequestImpl() to service the request, if handleRequestImpl() returns NOTHING, then it tries to automatically serve a matching template or files from the filesystem or serve the default resource if no resource can be matched More... | |
*hash | handleRequestImpl (reference cx, hash hdr, *data body) |
this method is called by this class's handleRequest() before trying to service the request automatically based on file resources More... | |
logDebug (string fmt) | |
default implementation is empty; this method is called with debug log messages; reimplement in subclasses to provide for logging | |
logError (string fmt) | |
default implementation is empty; this method is called with error log messages; reimplement in subclasses to provide for logging | |
logInfo (string fmt) | |
default implementation is empty; this method is called with informational log messages; reimplement in subclasses to provide for logging | |
*hash | renderDirectory (hash cx, string path) |
this method is called when a directory should be rendered More... | |
hash | serverError (hash cx, hash ex) |
this method returns a 500 "Internal Server Error" error code when an exception occurs More... | |
WebUtil::FileHandler HttpServer::AbstractUrlHandler, WebUtil::TemplateFileManager | stm () |
static templates | |
hash | unhandledRequest (hash cx, hash hdr, *data body) |
this method returns a 404 "Not Found" error code to GET requests and a 501 "Not Implemented" error code to all other requests More... | |
create the object optionally with the given AbstractAuthenticator
file_root | the filesystem root directory for serving files |
url_root | the root part of the URL path without the leading "/" |
options | an optional with one or more of the following option keys:
|
this method returns a 400 "Bad Request"
error code when a file should be served that's not a regular file
this method is called when a file cannot be served because it's not a regular file; reimplement this method in subclasses to customize error handling
this method calls handleRequestImpl() to service the request, if handleRequestImpl() returns NOTHING, then it tries to automatically serve a matching template or files from the filesystem or serve the default resource if no resource can be matched
cx | call context hash; this hash will have the following keys:
|
hdr | incoming header hash; all keys will be converted to lower-case, additionally the following keys will be present:
|
body | message body, if any |
"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 responseThe following keys are added to the cx argument when calling handleRequestImpl():
resource_path:
the relative path without any query arguments and with the URL root stripped off (if the request was matched by the URL root, otherwise this will be the request path with any URI query arguments removed)url_root:
the root URLfile_root:
the root directory for serving filesisregex:
if the url_root string is a regular expression or not (this is always False when this class is used)hdr:
this is added to the cx argument directly from the hdr argument, however it also includes the "params"
key which holds the URI query parameters as returned in the params key from HttpServer::parse_uri_query()If handleRequestImpl() returns NOTHING and the requested path cannot be matched and served, then unhandledRequest() is called to handle the error
this method is called by this class's handleRequest() before trying to service the request automatically based on file resources
cx | call context hash; this hash will have the following keys:
|
hdr | incoming header hash; all keys will be converted to lower-case, additionally the following keys will be present:
|
body | message body, if any |
"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 responseresource_path
, url_root
, and isregex
this method returns a 500 "Internal Server Error"
error code when an exception occurs
this method is called when an exception occurs; reimplement this method in subclasses to customize error handling
this method returns a 404 "Not Found"
error code to GET
requests and a 501 "Not Implemented"
error code to all other requests
this method is called when a request cannot be handled; reimplement this method in subclasses to customize unhandled request error handling