3#include <uwebsockets/App.h>
39 std::function<std::expected<void, std::string>(std::string driver, std::string adapter)>;
45 using GetLogFn = std::function<std::vector<std::string>()>;
53 using RefreshCertFn = std::function<std::expected<void, std::string>()>;
90 std::string
corsOrigin{
"https://motion-master.synapticon.com"};
136 std::vector<mm::api::RegisterRoutesFn> routeModules_;
137 std::atomic<bool> running_{
false};
139 std::atomic<uWS::Loop*> loop_{
nullptr};
140 std::atomic<uWS::SSLApp*> app_{
nullptr};
142 std::promise<bool> listenResult_;
HTTPS REST API server.
Definition http_server.h:29
std::function< std::expected< void, std::string >(uint32_t periodUs)> SetGameLoopPeriodFn
Callback type for PUT /api/game-loop.
Definition http_server.h:71
~HttpServer()
Destructor. Calls stop() if the server is still running.
Definition http_server.cc:277
std::function< std::expected< void, std::string >(std::string driver, std::string adapter)> InitDeviceManagerFn
Callback type for POST /api/init.
Definition http_server.h:39
void addRoutes(mm::api::RegisterRoutesFn module)
Registers a route plug-in to be wired in when the server starts.
Definition http_server.cc:285
std::function< std::vector< std::string >()> GetLogFn
Callback type for GET /api/log.
Definition http_server.h:45
std::function< std::expected< void, std::string >()> RefreshCertFn
Callback type for POST /api/cert/refresh.
Definition http_server.h:53
void stop()
Stops the server, closes the listen socket, and joins the thread.
Definition http_server.cc:304
std::function< GameLoopHealth()> GetGameLoopHealthFn
Callback type for GET /api/game-loop.
Definition http_server.h:61
bool start()
Starts the server background thread and begins accepting connections.
Definition http_server.cc:293
Owns the fieldbus driver and node collection, and drives PDO exchange.
Definition device_manager.h:183
Owns the active monitorings and turns each into a lossless stream of recorded rows.
Definition monitoring_manager.h:46
std::function< void(uWS::SSLApp &app, const RouteContext &ctx)> RegisterRoutesFn
A route plug-in: registers its routes on the HTTP app.
Definition web_api.h:57
Definition http_server.h:16
The whole config file. Top-level keys map to these members.
Definition config.h:100
Snapshot of game-loop real-time health for the GET /api/game-loop diagnostic endpoint....
Definition game_loop.h:14
Server configuration.
Definition http_server.h:74
RefreshCertFn refreshCert
Handler for POST /api/cert/refresh; fetches+installs a cert.
Definition http_server.h:84
GetGameLoopHealthFn getGameLoopHealth
Handler for GET /api/game-loop; RT loop health snapshot.
Definition http_server.h:86
GetLogFn getLog
Handler for GET /api/log; returns buffered log entries.
Definition http_server.h:83
std::string startedConfig
Serialized JSON of the boot config; served at GET /api/config.
Definition http_server.h:80
std::string version
Application version string served at GET /api/version.
Definition http_server.h:78
InitDeviceManagerFn initDeviceManager
Handler for POST /api/init; required for API-driven init.
Definition http_server.h:82
uint16_t port
TCP port to listen on (TLS).
Definition http_server.h:75
std::string certFile
Path to the TLS certificate (PEM).
Definition http_server.h:76
std::string keyFile
Path to the TLS private key (PEM).
Definition http_server.h:77
std::string corsOrigin
Value sent in Access-Control-Allow-Origin. Defaults to the production PWA origin.
Definition http_server.h:90
SetGameLoopPeriodFn setGameLoopPeriod
Definition http_server.h:88