#include <JodaServer.h>
|
bool | start (const std::string &addr, int port) |
|
void | stop () |
|
|
static constexpr auto | prefix = "/api" |
|
JodaServer is responsible for initializing and starting a HTTP server providing netwok functionality to JODA
◆ handleError()
void joda::network::JodaServer::handleError |
( |
JodaAPIException & |
e, |
|
|
httplib::Response & |
res |
|
) |
| |
|
static |
Helper function for the API to use. It uses the error message contained in a JodaAPIException to send a http response containing the error message.
- Parameters
-
e | the exception to extract the error message from |
res | the response over which the error will be reported to the client |
◆ logExecutionTime()
template<class F >
static void joda::network::JodaServer::logExecutionTime |
( |
const std::string & |
endpoint, |
|
|
F |
f |
|
) |
| |
|
inlinestatic |
Helper function for the API to use. It executes a function, times it's execution and logs this time.
- Parameters
-
endpoint | a string describing which API endpoint the function comes from |
f | function to execute and time |
◆ sendResponse()
void joda::network::JodaServer::sendResponse |
( |
RJDocument & |
doc, |
|
|
httplib::Response & |
res |
|
) |
| |
|
static |
Helper function for the API to use. It serializes a JSON document and sends it over a http response to the client.
- Parameters
-
doc | the document to send to the client |
res | the response over which the document will be sent to the client |
◆ start()
bool joda::network::JodaServer::start |
( |
const std::string & |
addr, |
|
|
int |
port |
|
) |
| |
Starts the server synchronously.
- Parameters
-
addr | the address to bind the server to (e.g.: 0.0.0.0 or 127.0.0.1) |
port | the port to bind the server to |
- Returns
- false if server could not be started.
◆ stop()
void joda::network::JodaServer::stop |
( |
| ) |
|
Stops the server. The "start" function will return after executing this function.
◆ prefix
constexpr auto joda::network::JodaServer::prefix = "/api" |
|
staticconstexpr |
The prefix is used to specify where the JODA api endpoint should be. "http://<host>:<port><prefix><...>"
The documentation for this class was generated from the following files:
- /home/nico/joda_tmp/tmp-joda-dirs/JODA-gh/libs/joda/core/modules/network/include/joda/network/JodaServer.h
- /home/nico/joda_tmp/tmp-joda-dirs/JODA-gh/libs/joda/core/modules/network/src/JodaServer.cpp