tufao
1.3.0
An asynchronous web framework for C++ built on top of Qt
|
This class serves as the HttpServerRequestHandler for all ClassHandler plugins. More...
Public Slots | |
bool | handleRequest (HttpServerRequest &request, HttpServerResponse &response) override |
Public Member Functions | |
ClassHandlerManager (const QString &pluginID=QString{}, const QString &urlNamespace=QString{}, QObject *parent=0) | |
Constructs a ClassHandlerManager object. More... | |
virtual | ~ClassHandlerManager () |
Destroys the object. | |
QString | urlNamespace () const |
Public Member Functions inherited from Tufao::AbstractHttpServerRequestHandler | |
operator std::function< bool (HttpServerRequest &, HttpServerResponse &)>() | |
Implicit conversion operator to std::function functor object. More... | |
virtual bool | handleRequest (Tufao::HttpServerRequest &request, Tufao::HttpServerResponse &response)=0 |
Handles the request using the response object. More... | |
Static Public Member Functions | |
static void | addPluginLocation (const QString location) |
Adds a non-standard path to the search paths. More... | |
Properties | |
QString | urlNamespace |
This class serves as the HttpServerRequestHandler for all ClassHandler plugins.
This class is used to mange one or more ClassHandler plugins. To use this class, you simply instantiate and register with the HttpServerRequestRouter. You can specify that an instane of this class is only to manager plugins with a particular IID, and you can also assign a urlNamespace (the path's prefix of a URL).
If you specify a urlNamespace at creation time, only URL's whose path have that string as the prefix (case-sensitive) will receive dispatches. It's important to use a string that begins with "/" as the urlNamespace.
Also, requests whose url's path start with urlNamespace, but have some character different than '/' following are not considered to be within the same urlNamespace and will be ignored. This means that if you choose "/forum" as urlNamespace, requests to "/forumb" will be ignored. You're safe.
Static plugins will be registered be the first instance of this class created, regardless of if they specify an IID (as IID is not available at runtime for static plugins). Otehrwise, only plugins that have a matching IID to the plginID provided will be loaded by this instance.
To have a single instance load and regiser all plugins, simply leave the pluginID blank.
If urlNamespace is used, in your ClassHandler instances you will likely need to pass the value of the urlNamespace out into your response so that things like URL's in HTML or Ajaz calls can prepend the urlNamespace to their paths; otherwise the calls will fail.
|
explicit |
Constructs a ClassHandlerManager object.
pluginID | if provided, this instance will only load plugins whose IID matches. |
urlNamespace | if provided, this is the urlNamespace (requests whose url's path start with urlNamespace) for the plugins managed by this instance. Before dispatching a request to one of the plugins, the cotext is checked, and only if it matches does the request get dispatched. |
parent | is passed to the QObject constructor. |
|
static |
Adds a non-standard path to the search paths.
By default, the standard locations are searched for plugins. The standard paths are the system library paths with a Tufao sub-directory, the executable path, and the applications configutation directory; on linux, ~/.tufao, and on Mac both /Library/Application Support/Tufao and ~/Library/Application Support/Tufao. Each of these directories is search to see if it has a plugins sud-directoy, and if it does, all dynamic libraries in each matching directroy is examined to determine if it is a plugin.
location | an absolute path to be added to the search paths for plugins. |