Qorus Integration Engine® Enterprise Edition 6.0.15_prod
Loading...
Searching...
No Matches
OMQ::AbstractServiceRestHandler Class Reference

This class is used to customize and control the behavior of the Qorus HTTP server. More...

Inheritance diagram for OMQ::AbstractServiceRestHandler:
[legend]
Collaboration diagram for OMQ::AbstractServiceRestHandler:
[legend]

Public Member Methods

 constructor (string path, bool isregex=False, HttpServer::AbstractAuthenticator auth=new DefaultQorusRBACAuthenticator(), *RestSchemaValidator::AbstractRestSchemaValidator validator)
 creates the object with the given arguments More...
 
 constructor (string path, HttpServer::AbstractAuthenticator auth=new DefaultQorusRBACAuthenticator(), *RestSchemaValidator::AbstractRestSchemaValidator validator)
 creates the object with the given arguments 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
 
 removeRootPath (reference path)
 removes the root path from the URL
 
- 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 from hash elements describing the listener More...
 
final *hash< auto > saveThreadLocalData ()
 called before handleRequest() More...
 
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. More...
 
string getRequestPath (string hpath)
 returns the request path with the common leading part of the URL and also any URI query argument stripped
 
*hash< auto > handleRequestImpl (reference< hash< auto > > cx, hash< auto > hdr, *data body)
 This method is called by this class's handleRequest() More...
 
 setDefaultResource (string name)
 sets the default service file resource to be rendered More...
 
 setThreadContext (hash< auto > cx)
 Sets the service thread context. More...
 

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
 
static setServiceThreadContext (hash< auto > cx)
 Sets the service thread context. More...
 
- 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 More...
 
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
 
- Private Member Methods inherited from OMQ::AbstractServiceHttpHandler
AbstractStreamRequest getStreamRequestImpl (HttpListenerInterface listener, Socket s, hash< auto > cx, hash< auto > hdr, *data body)
 returns the AbstractStreamRequest object for handling chunked requests
 
AbstractServiceStream getServiceStreamRequestImpl (Socket s, hash< auto > cx, hash< auto > hdr, *data body)
 returns the AbstractStreamRequest object for handling chunked requests
 

Detailed Description

This class is used to customize and control the behavior of the Qorus HTTP server.

This class redirects URLs to Qorus services providing HTTP-based REST services If any listeners are added to the AbstractServiceRestHandler object, then the URL set in the object is only bound to the new listeners specified in this object.

Otherwise, the URL is bound to all listeners in the system HTTP server.

Note
When used in Stateless services, HTTP and REST handlers are identified by a unique ID that is generated from the options used to create the object. To ensure that all stateless services use the same ID, you must ensure that the same options are used in each service's bindHttp() call. Failure to do this, for example my using a randomly-generated strings in the constructor, will cause runtime errors.

Member Function Documentation

◆ constructor() [1/2]

OMQ::AbstractServiceRestHandler::constructor ( string  path,
bool  isregex = False,
HttpServer::AbstractAuthenticator  auth = new DefaultQorusRBACAuthenticator(),
*RestSchemaValidator::AbstractRestSchemaValidator  validator 
)

creates the object with the given arguments

Parameters
paththe string or regular expression for the path to match on incoming requests (ex "my-service")
isregexdetermines if path is a regular expression or simply the leading path component
auththe AbstractAuthenticator for the object; if no argument is passed, then 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
validatoran optional REST schema validator object to validate and process incoming and outgoing requests
Example:
class MyRestHandler inherits AbstractServiceRestHandler {
constructor() : AbstractServiceRestHandler("my-service", svc_get_resource_data("my-swagger-schema-v1.0.yaml")) {
}
}
Note
that the path argument defaults to a string instead of a regular expression in this constructor

◆ constructor() [2/2]

OMQ::AbstractServiceRestHandler::constructor ( string  path,
HttpServer::AbstractAuthenticator  auth = new DefaultQorusRBACAuthenticator(),
*RestSchemaValidator::AbstractRestSchemaValidator  validator 
)

creates the object with the given arguments

Parameters
paththe string or regular expression for the path to match on incoming requests (ex "my-service")
auththe AbstractAuthenticator for the object; if no argument is passed, then 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
validatoran optional REST schema validator object to validate and process incoming and outgoing requests
Example:
class MyRestHandler inherits AbstractServiceRestHandler {
constructor() : AbstractServiceRestHandler("my-service", svc_get_resource_data("my-swagger-schema-v1.0.yaml")) {
}
}
Note
that the path argument defaults to a string instead of a regular expression in this constructor
Since
Qorus 4.0.3

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