QtWebApp
stefanfrings::HttpRequestHandler Class Reference

The request handler generates a response for each HTTP request. More...

#include <httprequesthandler.h>

Inheritance diagram for stefanfrings::HttpRequestHandler:
Collaboration diagram for stefanfrings::HttpRequestHandler:

Public Member Functions

 HttpRequestHandler (QObject *parent=nullptr)
 Constructor. More...
 
virtual ~HttpRequestHandler ()
 Destructor. More...
 
virtual void service (HttpRequest &request, HttpResponse &response)
 Generate a response for an incoming HTTP request. More...
 

Detailed Description

The request handler generates a response for each HTTP request.

Web Applications usually have one central request handler that maps incoming requests to several controllers (servlets) based on the requested path.

You need to override the service() method or you will always get an HTTP error 501.

Warning
Be aware that the main request handler instance must be created on the heap and that it is used by multiple threads simultaneously.
See also
StaticFileController which delivers static local files.

Definition at line 27 of file httprequesthandler.h.

Constructor & Destructor Documentation

◆ HttpRequestHandler()

HttpRequestHandler::HttpRequestHandler ( QObject *  parent = nullptr)

Constructor.

Parameters
parentParent object.

Definition at line 10 of file httprequesthandler.cpp.

◆ ~HttpRequestHandler()

HttpRequestHandler::~HttpRequestHandler ( )
virtual

Destructor.

Definition at line 14 of file httprequesthandler.cpp.

Member Function Documentation

◆ service()

void HttpRequestHandler::service ( HttpRequest request,
HttpResponse response 
)
virtual

Generate a response for an incoming HTTP request.

Parameters
requestThe received HTTP request
responseMust be used to return the response
Warning
This method must be thread safe

Reimplemented in stefanfrings::StaticFileController.

Definition at line 17 of file httprequesthandler.cpp.


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