Qorus Integration Engine®  4.0.3.p2_git
OMQ::ServiceFileHandler Class Reference

this class supports the implementation of HTTP file-based request handler with automatic handling of files in a certain root directory as well as rendering of templates More...

Inheritance diagram for OMQ::ServiceFileHandler:
WebUtil::FileHandler OMQ::AbstractServiceHttpHandler HttpServer::AbstractUrlHandler WebUtil::TemplateFileManager HttpServer::AbstractHttpRequestHandler HttpServer::AbstractHttpRequestHandler

Public Member Methods

 constructor (string file_root, string url_root, *hash< auto > opt)
 create the object optionally with the given AbstractAuthenticator More...
 
hash< HttpResponseInfo > handleRequest (HttpListenerInterface listener, Socket s, hash< auto > cx, hash< auto > hdr, *data body)
 this method ensures that thread-local data is set properly
 
- Public Member Methods inherited from OMQ::AbstractServiceHttpHandler
OMQ::ThreadLocalData otld ()
 thread-local data to add before calling handleRequest()
 
 constructor (string n_path, *softlist< auto > n_content_type, *softlist< auto > n_special_headers, HttpServer::AbstractAuthenticator n_auth=new DefaultQorusRBACAuthenticator(), bool n_isregex=True)
 creates the object with the given arguments More...
 
hash< auto > getServiceInfo ()
 returns a hash with info about the linked service
 
 addListener (hash< HttpServer::HttpListenerOptionInfo > opt)
 adds a listener from a bind string in the format: "address:port" (ex: "192.168.20.1:8011") More...
 
 addListener (softstring bind, hash< HttpServer::HttpListenerOptionInfo > opt)
 adds a listener from a bind string in the format: "address:port" (ex: "192.168.20.1:8011") More...
 
 addListener (softstring bind, *string cert_path, *string key_path, *string key_password, *hash< HttpServer::HttpListenerOptionInfo > opt)
 adds a listener from a bind string in the format: "address:port" (ex: "192.168.20.1:8011") More...
 
 addListener (softstring bind, *Qore::SSLCertificate cert, *Qore::SSLPrivateKey key, *hash< HttpServer::HttpListenerOptionInfo > opt)
 adds a listener from a bind string in the format: "address:port" (ex: "192.168.20.1:8011") More...
 
 addListeners (softlist< auto > l)
 adds a list of listeners; each element should be either a bind string in the format: "address:port" (ex: "192.168.20.1:8011") or an integer port, meaning to bind on all interfaces on that port More...
 
final *hash< auto > saveThreadLocalData ()
 called before handleRequest() any data returned here will be given to restoreThreadLocalData() after the handleRequest() call
 
final restoreThreadLocalData (*hash< auto > data)
 called after handleRequest() with any data returned from saveThreadLocalData()
 
 log (int ll, string fmt)
 logs to the service log file
 
 setUserIndexInfo (string heading, string title, string url)
 sets heading and title for user HTTP services
 
 clearUserIndexInfo ()
 clears heading and title into for user HTTP services More...
 
hash< HttpResponseInfo > handleRequest (HttpListenerInterface listener, Socket s, hash< auto > cx, hash< auto > hdr, *data body)
 this method ensures that thread-local data is set properly
 
hash< auto > handleRequest (hash< auto > cx, hash< auto > hdr, *data body)
 this method calls handleRequestImpl() to service the request, if handleRequestImpl() returns NOTHING, then it tries to automatically serve service file resources or serve the default resource if no resource can be matched More...
 
string getRequestPath (string hpath)
 returns the request path with the common leading part of the URL stripped off and also any URI query argument stripped off
 
*hash< auto > handleRequestImpl (reference< hash< auto >> cx, hash< auto > hdr, *data body)
 this method is called by this class's handleRequest() before trying to service the request automatically based on service file resources More...
 
 setDefaultResource (string name)
 sets the default service file resource to be rendered when the request is not matched to a resource and handleRequestImpl() does not return a response
 
private AbstractStreamRequest getStreamRequestImpl (HttpListenerInterface listener, Socket s, hash< auto > cx, hash< auto > hdr, *data body)
 returns the AbstractStreamRequest object for handling chunked requests
 
private AbstractServiceStream getServiceStreamRequestImpl (Socket s, hash< auto > cx, hash< auto > hdr, *data body)
 returns the AbstractStreamRequest object for handling chunked requests
 

Additional Inherited Members

- Static Public Member Methods inherited from OMQ::AbstractServiceHttpHandler
static AbstractServiceStream getServiceStreamRequestExtern (AbstractServiceHttpHandler hr, Socket s, hash< auto > cx, hash< auto > hdr, *data body)
 for calling the getServiceStreamRequestImpl() externally
 
- Public Attributes inherited from OMQ::AbstractServiceHttpHandler
string url
 The path string or regex to match incoming requests.
 
*softlist< auto > content_type
 the content-type to check
 
*softlist< auto > special_headers
 list of special headers; if a request has any of these HTTP headers, then the requests will match this handler
 
list< auto > listeners = ()
 list of listener info; do not write to this list directly, use AbstractServiceHttpHandler::addListener() instead (the internal format may change)
 
code svcc
 a closure that allows specific Service methods to be called
 
code svc_method_call
 a closure that allows any Service methods to be called
 
*string utype
 the type/heading for user HTTP services
 
*string utitle
 the title for user HTTP services
 
*string uurl
 the URL for user HTTP services
 
bool isregex
 if the path is a regex or a string
 
*string default_resource
 the default resource to serve
 
hash< auto > svcinfo
 service info hash
 

Detailed Description

this class supports the implementation of HTTP file-based request handler with automatic handling of files in a certain root directory as well as rendering of templates

Member Function Documentation

◆ constructor()

OMQ::ServiceFileHandler::constructor ( string  file_root,
string  url_root,
*hash< auto >  opt 
)

create the object optionally with the given AbstractAuthenticator

Parameters
file_rootthe filesystem root directory for serving files
url_rootthe root part of the URL path without the leading "/"
optan optional with one or more of the following option keys:
  • default_target: the default relative path to use if a request cannot be satisfied
  • po: the Program parse options for the template file programs
  • psetup: an optional closure or call reference taking a single Program argument to be called when initializing template programs to set up a custom template API, etc
  • auth: the authentication object to use to authenticate connections (see AbstractAuthenticator); if no AbstractAuthenticator object is passed, then by default the system RBAC authenticator is used; meaning that Qorus application users are required to connect, and the users must have the OMQ::QR_LOGIN role to connect as well
  • error_level: the level of error reporting (0, 1, or 2)

The documentation for this class was generated from the following file: