JODA  0.13.1 (59b41972)
JSON On-Demand Analysis
Public Member Functions | Static Public Member Functions | Static Public Attributes
joda::network::JodaServer Class Reference

#include <JodaServer.h>

Public Member Functions

bool start (const std::string &addr, int port)
 
void stop ()
 

Static Public Member Functions

static void handleError (JodaAPIException &e, httplib::Response &res)
 
static void sendResponse (RJDocument &doc, httplib::Response &res)
 
template<class F >
static void logExecutionTime (const std::string &endpoint, F f)
 

Static Public Attributes

static constexpr auto prefix = "/api"
 

Detailed Description

JodaServer is responsible for initializing and starting a HTTP server providing netwok functionality to JODA

Member Function Documentation

◆ 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
ethe exception to extract the error message from
resthe response over which the error will be reported to the client
Here is the caller graph for this function:

◆ logExecutionTime()

template<class F >
static void joda::network::JodaServer::logExecutionTime ( const std::string &  endpoint,
f 
)
inlinestatic

Helper function for the API to use. It executes a function, times it's execution and logs this time.

Parameters
endpointa string describing which API endpoint the function comes from
ffunction to execute and time
Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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
docthe document to send to the client
resthe 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
addrthe address to bind the server to (e.g.: 0.0.0.0 or 127.0.0.1)
portthe port to bind the server to
Returns
false if server could not be started.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ stop()

void joda::network::JodaServer::stop ( )

Stops the server. The "start" function will return after executing this function.

Here is the caller graph for this function:

Field Documentation

◆ 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: