Motion Master 6.0.0-alpha.50
Next-generation motion control software
Loading...
Searching...
No Matches
mm::api::RouteContext Struct Reference

The live collaborators a route plug-in needs, handed to it at registration time. More...

#include <web_api.h>

Collaboration diagram for mm::api::RouteContext:
[legend]

Public Attributes

mm::node::DeviceManagerdeviceManager
 Device list + SDO/PDO/state/bus access.
 
mm::node::MonitoringManagermonitoringManager
 Monitoring registry (for monitoring-aware plug-ins).
 
std::string_view corsOrigin
 Value to send in Access-Control-Allow-Origin; outlives run().
 

Detailed Description

The live collaborators a route plug-in needs, handed to it at registration time.

A plug-in's RegisterRoutesFn receives this by const reference. The referenced objects (DeviceManager / MonitoringManager) and the storage backing corsOrigin all outlive the running server, so a handler may safely capture the individual fields it needs — but it must **never capture the RouteContext itself**, which is a temporary that dies once registration returns. Capture the fields instead:

void registerRoutes(uWS::SSLApp& app, const mm::api::RouteContext& ctx) {
app.get("/api/example/devices", [&dm = ctx.deviceManager, cors = ctx.corsOrigin](
auto* res, auto* /*req*/) {
mm::api::sendJson(res, cors, summarize(dm));
});
}
The live collaborators a route plug-in needs, handed to it at registration time.
Definition web_api.h:39
std::string_view corsOrigin
Value to send in Access-Control-Allow-Origin; outlives run().
Definition web_api.h:45
mm::node::DeviceManager & deviceManager
Device list + SDO/PDO/state/bus access.
Definition web_api.h:41

Member Data Documentation

◆ corsOrigin

std::string_view mm::api::RouteContext::corsOrigin

Value to send in Access-Control-Allow-Origin; outlives run().

◆ deviceManager

mm::node::DeviceManager& mm::api::RouteContext::deviceManager

Device list + SDO/PDO/state/bus access.

◆ monitoringManager

mm::node::MonitoringManager& mm::api::RouteContext::monitoringManager

Monitoring registry (for monitoring-aware plug-ins).


The documentation for this struct was generated from the following file: