This class is responsible for encapsulating the QCoreApplication, the CppWebServer and configure the server logging mechanism.
More...
#include <cppwebapplication.h>
|
| | CppWebApplication (int argc, char *argv[], const QString &serverPath, Filter *filter=nullptr) |
| | Constructs a QCoreApplication, a CppWebServer and install the message handler. if the server folder's path was not found in the serverPath, it will look into the executable's folder. More...
|
| |
|
| ~CppWebApplication () |
| | Destroys the server dynamically allocated.
|
| |
| template<typename CONTROLLER > |
| void | addController (const QString &url) noexcept |
| | Hitches a url to a Controller. More...
|
| |
| int | start () |
| | Starts the server and QCoreApplication. More...
|
| |
This class is responsible for encapsulating the QCoreApplication, the CppWebServer and configure the server logging mechanism.
◆ CppWebApplication()
| CppWebApplication::CppWebApplication |
( |
int |
argc, |
|
|
char * |
argv[], |
|
|
const QString & |
serverPath, |
|
|
Filter * |
filter = nullptr |
|
) |
| |
Constructs a QCoreApplication, a CppWebServer and install the message handler. if the server folder's path was not found in the serverPath, it will look into the executable's folder.
- Parameters
-
| int | argc : Main function parameter used to build QCoreApplication. |
| char | *argv[] : Main function parameter used to build QCoreApplication. |
| const | Configuration &config : Used to set the parameters of the server. |
| Filter | *filter : Install a filter for requests on the server. |
◆ addController()
template<typename CONTROLLER >
| void CppWebApplication::addController |
( |
const QString & |
url | ) |
|
|
inlinenoexcept |
Hitches a url to a Controller.
- Parameters
-
| const | QString &url : Url name. |
| Controller | *controller : Controller that will answer requests made to url. |
- Example
#include <QCoreApplication>
#include <controllers/helloworldcontroller.h>
#include <cwf/cppwebapplication.h>
int main(int argc, char *argv[])
{
CWF::CppWebApplication server(argc, argv, "/PATH_TO_EXAMPLE/server"));
server.addUrlController<HelloWorldController>("/hello");
return server.start();
}
◆ start()
| int CppWebApplication::start |
( |
| ) |
|
Starts the server and QCoreApplication.
- Returns
- int : Returns -1 if it fails.
The documentation for this class was generated from the following files:
- /home/herik/CPPWebFramework/CPPWebFramework/cwf/cppwebapplication.h
- /home/herik/CPPWebFramework/CPPWebFramework/cwf/cppwebapplication.cpp