tufao  0.8.1
An asynchronous web framework for C++ built on top of Qt
 All Classes Namespaces Functions Variables Enumerations Enumerator Pages
Tufao::HttpPluginServer Class Reference

This class provides a plugin-based request handler. More...

+ Inheritance diagram for Tufao::HttpPluginServer:
+ Collaboration diagram for Tufao::HttpPluginServer:

Public Slots

bool handleRequest (Tufao::HttpServerRequest *request, Tufao::HttpServerResponse *response, const QStringList &args=QStringList())
 Handle the request using the loaded plugins and rules.
 
void reloadConfig ()
 Clear all previous mappings and reload all rules and plugins. More...
 
- Public Slots inherited from Tufao::AbstractHttpServerRequestHandler
virtual bool handleRequest (Tufao::HttpServerRequest *request, Tufao::HttpServerResponse *response, const QStringList &args=QStringList())=0
 Handles the request using the response object. More...
 

Public Member Functions

 HttpPluginServer (const QString &configFile=QString(), QObject *parent=0)
 Constructs a HttpPluginServer object. More...
 
 HttpPluginServer (const QString &configFile, bool autoreload, QObject *parent=0)
 Constructs a HttpPluginServer object. More...
 
 ~HttpPluginServer ()
 Destroys the object.
 
void setConfig (const QString &file)
 This is an overloaded function. More...
 
void setConfig (const QString &file, bool autoreload)
 Set the configuration file used to handle requests. More...
 
QString config () const
 Return the current used configuration file. More...
 
- Public Member Functions inherited from Tufao::AbstractHttpServerRequestHandler
 AbstractHttpServerRequestHandler (QObject *parent=0)
 Constructs an AbstractHttpServerRequestHandler object.
 

Detailed Description

This class provides a plugin-based request handler.

Use it if you need to change the running server code without need to restart the appplication.

It maintains its own set of rules and is as powerful as HttpServerRequestRouter (and internally uses it), but, in contrast, exports its configuration through a file and will use handlers loaded from plugins.

The file use a syntax based on the QSettings ini format and can edit it using tufao-routes-editor.

Note
If you want to control when the plugins are reloaded, you must ensure that autoreload is false and explicitly call the slot HttpPluginServer::reloadConfig.
See Also
AbstractHttpServerRequestHandlerFactory to implement your plugins.
Tufão's plugin system
Since
0.3

Constructor & Destructor Documentation

Tufao::HttpPluginServer::HttpPluginServer ( const QString &  configFile = QString(),
QObject *  parent = 0 
)
explicit

Constructs a HttpPluginServer object.

Parameters
configFileIt's used as configuration file.
parentIt's passed to the QObject constructor.
Warning
The object created by this constructor doesn't autoreload the config file when it changes. You can use another constructor or call HttpPluginServer::setConfig if you want a different behaviour.
Tufao::HttpPluginServer::HttpPluginServer ( const QString &  configFile,
bool  autoreload,
QObject *  parent = 0 
)
explicit

Constructs a HttpPluginServer object.

Parameters
configFileIt's used as configuration file.
autoreloadWhether HttpPluginServer will autoreload the config file when it is modified.
parentIt's passed to the QObject constructor.
Since
0.8

Member Function Documentation

QString Tufao::HttpPluginServer::config ( ) const

Return the current used configuration file.

This file is used to handle requests, loading the appropriate plugins, generating actual handlers and mapping them to the rules described in this file.

void Tufao::HttpPluginServer::reloadConfig ( )
slot

Clear all previous mappings and reload all rules and plugins.

If you want to control when the plugins are reloaded, you must ensure that autoreload is false and explicitly call this slot when you want to make the changes of the config file take effect.

This is an advanced use of HttpPluginServer and you probably just want to ensure autoreload is true to avoid unnecessary complexities.

void Tufao::HttpPluginServer::setConfig ( const QString &  file)

This is an overloaded function.

It will NOT autoreload the config referenced by file.

void Tufao::HttpPluginServer::setConfig ( const QString &  file,
bool  autoreload 
)

Set the configuration file used to handle requests.

Call this function will reload the configuration.

autoreload tells whether HttpPluginServer should autoreload the config file when it is modified.

See Also
config
Since
0.8

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