QHttpEngine
1.0.0
Simple and secure HTTP server for Qt applications
|
Handler for invoking slots More...
#include <qhttpengine/qobjecthandler.h>
Public Member Functions | |
QObjectHandler (QObject *parent=0) | |
Create a new QObject handler. | |
void | registerMethod (const QString &name, QObject *receiver, const char *method, bool readAll=true) |
Register a method. More... | |
void | registerMethod (const QString &name, QObject *receiver, PointerToMemberFunction method, bool readAll=true) |
Register a method. More... | |
void | registerMethod (const QString &name, Functor functor, bool readAll=true) |
Register a method. More... | |
void | registerMethod (const QString &name, QObject *receiver, Functor functor, bool readAll=true) |
Register a method. More... | |
![]() | |
Handler (QObject *parent=0) | |
Base constructor for a handler. | |
void | addMiddleware (Middleware *middleware) |
Add middleware to the handler. | |
void | addRedirect (const QRegExp &pattern, const QString &path) |
Add a redirect for a specific pattern. More... | |
void | addSubHandler (const QRegExp &pattern, Handler *handler) |
Add a handler for a specific pattern. More... | |
void | route (Socket *socket, const QString &path) |
Route an incoming request. | |
Protected Member Functions | |
virtual void | process (Socket *socket, const QString &path) |
Reimplementation of [Handler::process()](QHttpEngine::Handler::process) | |
Friends | |
class | QObjectHandlerPrivate |
This handler enables incoming requests to be processed by slots in a QObject-derived class or functor. Methods are registered by providing a name and slot to invoke. The slot must take a pointer to the Socket for the request as an argument and must also close the socket when finished with it.
To use this class, simply create an instance and call the appropriate registerMethod() overload. For example:
It is also possible to use this class with a functor, eliminating the need to create a class and slot:
void QHttpEngine::QObjectHandler::registerMethod | ( | const QString & | name, |
QObject * | receiver, | ||
const char * | method, | ||
bool | readAll = true |
||
) |
This overload uses the traditional connection syntax with macros.
The readAll parameter determines whether all data must be received by the socket before invoking the slot.
void QHttpEngine::QObjectHandler::registerMethod | ( | const QString & | name, |
QObject * | receiver, | ||
PointerToMemberFunction | method, | ||
bool | readAll = true |
||
) |
This overload uses the new connection syntax with member pointers.
void QHttpEngine::QObjectHandler::registerMethod | ( | const QString & | name, |
Functor | functor, | ||
bool | readAll = true |
||
) |
This overload uses the new functor syntax (without context).
void QHttpEngine::QObjectHandler::registerMethod | ( | const QString & | name, |
QObject * | receiver, | ||
Functor | functor, | ||
bool | readAll = true |
||
) |
This overload uses the new functor syntax (with context).