C++ Web Framework  3.0
Public Member Functions | List of all members
CppWebApplication Class Reference

This class is responsible for encapsulating the QCoreApplication, the CppWebServer and configure the server logging mechanism. More...

#include <cppwebapplication.h>

Public Member Functions

 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...
 

Detailed Description

This class is responsible for encapsulating the QCoreApplication, the CppWebServer and configure the server logging mechanism.

Constructor & Destructor Documentation

◆ 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
intargc : Main function parameter used to build QCoreApplication.
char*argv[] : Main function parameter used to build QCoreApplication.
constConfiguration &config : Used to set the parameters of the server.
Filter*filter : Install a filter for requests on the server.

Member Function Documentation

◆ addController()

template<typename CONTROLLER >
void CppWebApplication::addController ( const QString &  url)
inlinenoexcept

Hitches a url to a Controller.

Parameters
constQString &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: