tufao  1.3.0
An asynchronous web framework for C++ built on top of Qt
Tufao::ClassHandlerManager Class Reference

This class serves as the HttpServerRequestHandler for all ClassHandler plugins. More...

+ Inheritance diagram for Tufao::ClassHandlerManager:
+ Collaboration diagram for Tufao::ClassHandlerManager:

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
 

Detailed Description

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.

Since
1.2

Constructor & Destructor Documentation

Tufao::ClassHandlerManager::ClassHandlerManager ( const QString &  pluginID = QString{},
const QString &  urlNamespace = QString{},
QObject *  parent = 0 
)
explicit

Constructs a ClassHandlerManager object.

Parameters
pluginIDif provided, this instance will only load plugins whose IID matches.
urlNamespaceif 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.
parentis passed to the QObject constructor.

Member Function Documentation

static void Tufao::ClassHandlerManager::addPluginLocation ( const QString  location)
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.

Parameters
locationan absolute path to be added to the search paths for plugins.

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