#include <nawa/RequestHandler/RequestHandler.h>
Inherited by nawa::FastcgiRequestHandler, and nawa::HttpRequestHandler.
Definition at line 36 of file RequestHandler.h.
◆ RequestHandler()
nawa::RequestHandler::RequestHandler |
( |
| ) |
|
|
protected |
◆ ~RequestHandler()
RequestHandler::~RequestHandler |
( |
| ) |
|
|
virtual |
The overridden virtual destructor must terminate request handling and join worker threads, if not yet done. It also removes all stored session data to avoid a segfault during shutdown.
Definition at line 116 of file RequestHandler.cpp.
◆ newRequestHandler() [1/2]
Create a new request handler object according to the config. May throw a nawa::Exception on failure (passed on from the constructor of the specific request handler). The constructor of a request handler should set up everything that's necessary already here (as the constructor is the only function of a request handler which is executed with full privileges).
- Parameters
-
handleRequestFunction | A HandleRequestFunctionWrapper containing the handleRequest function of the app. |
config | The config. |
concurrency | Concurrency level (number of worker threads). |
- Returns
- A unique_ptr to the request handler.
Definition at line 101 of file RequestHandler.cpp.
◆ newRequestHandler() [2/2]
Create a new request handler object according to the config. May throw a nawa::Exception on failure (passed on from the constructor of the specific request handler). The constructor of a request handler should set up everything that's necessary already here (as the constructor is the only function of a request handler which is executed with full privileges).
- Parameters
-
handleRequestFunction | The handleRequest function of the app. |
config | The config. |
concurrency | Concurrency level (number of worker threads). |
- Returns
- A unique_ptr to the request handler.
Definition at line 110 of file RequestHandler.cpp.
◆ setAppRequestHandler()
Set or replace the handleRequest function of the app (thread-safe, blocking).
- Parameters
-
handleRequestFunction | The request handling function of the app. |
- Deprecated:
- Might be made private and non-blocking in v0.8 (or later), use reconfigure() instead.
Definition at line 45 of file RequestHandler.cpp.
◆ setAccessFilters()
Set or replace access filters for static request filtering (thread-safe, blocking).
- Parameters
-
accessFilters | The access filters. |
Definition at line 50 of file RequestHandler.cpp.
◆ getConfig()
std::shared_ptr< Config const > RequestHandler::getConfig |
( |
| ) |
const |
|
noexcept |
Get a pointer for reading the config.
- Returns
- Pointer to the config.
Definition at line 60 of file RequestHandler.cpp.
◆ setConfig()
void RequestHandler::setConfig |
( |
Config |
config | ) |
|
|
noexcept |
◆ reconfigure() [1/2]
Reconfigure the request handler (thread-safe, blocking).
- Parameters
-
handleRequestFunction | A HandleRequestFunctionWrapper containing the handleRequest function of the app. |
accessFilters | The access filters. |
config | The config. |
◆ reconfigure() [2/2]
Reconfigure the request handler (thread-safe, blocking).
- Parameters
-
handleRequestFunction | The request handling function of the app. |
accessFilters | The access filters. |
config | The config. |
Definition at line 79 of file RequestHandler.cpp.
◆ start()
virtual void nawa::RequestHandler::start |
( |
| ) |
|
|
pure virtual |
Start request handling. Must not block and return immediately if request handling is already running. May throw a nawa::Exception on failure during startup, but ideally, all actions which could lead to errors (or preliminary checks to avoid errors) should be done in the constructor, to avoid unnecessary initialization steps. Behavior of calling this function after join() has already been called is undefined, ideally, it should throw a nawa::Exception (proposed error code: 10). Please not that request handlers currently do NOT have to support restarting (i.e., calling stop, then start). The default FastCGI and HTTP request handlers do not support this and will not start request handling once again after stopping.
Implemented in nawa::FastcgiRequestHandler, and nawa::HttpRequestHandler.
◆ stop()
virtual void nawa::RequestHandler::stop |
( |
| ) |
|
|
pure virtualnoexcept |
Stop request handling after current requests have been served. Must not block and return immediately after the shutdown has been initiated. Must do nothing if request handling has already stopped or even joined.
Implemented in nawa::FastcgiRequestHandler, and nawa::HttpRequestHandler.
◆ terminate()
virtual void nawa::RequestHandler::terminate |
( |
| ) |
|
|
pure virtualnoexcept |
Enforce termination of request handling. Must not block and return immediately after the termination of request handling has been initiated (nevertheless, the termination should only take a few milliseconds after this function has been called). Must do nothing if request handling has already stopped or even joined.
Implemented in nawa::FastcgiRequestHandler, and nawa::HttpRequestHandler.
◆ restart()
virtual void nawa::RequestHandler::restart |
( |
| ) |
|
|
inlinevirtualnoexcept |
Restart request handling. Can optionally be supported by request handlers (the default request handlers for FastCGI and HTTP currently do NOT support this). If unsupported, this function does not have to be implemented, and will just do nothing.
Definition at line 150 of file RequestHandler.h.
◆ join()
virtual void nawa::RequestHandler::join |
( |
| ) |
|
|
pure virtualnoexcept |
Block until request handling has terminated. This is the only function that should block. If join has already been called, this function must return immediately, without throwing exceptions. By joining, the RequestHandler object becomes defunct and cannot be reused afterwards.
Implemented in nawa::FastcgiRequestHandler, and nawa::HttpRequestHandler.
◆ handleRequest()
void RequestHandler::handleRequest |
( |
Connection & |
connection | ) |
|
Handle request by processing the filters and calling the app's handleRequest function, if necessary. Internal function which should only be used by request handlers.
- Parameters
-
Definition at line 85 of file RequestHandler.cpp.
The documentation for this class was generated from the following files: