Motion Master 6.0.0-alpha.50
Next-generation motion control software
Loading...
Searching...
No Matches
web_api.h File Reference
#include <uwebsockets/App.h>
#include <functional>
#include <nlohmann/json.hpp>
#include <string>
#include <string_view>
Include dependency graph for web_api.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  mm::api::RouteContext
 The live collaborators a route plug-in needs, handed to it at registration time. More...
 

Namespaces

namespace  mm
 
namespace  mm::node
 
namespace  mm::api
 HTTP-transport glue shared by the built-in server and route plug-in libs.
 

Typedefs

using mm::api::RegisterRoutesFn = std::function< void(uWS::SSLApp &app, const RouteContext &ctx)>
 A route plug-in: registers its routes on the HTTP app.
 

Functions

template<typename Res >
void mm::api::sendJson (Res *res, std::string_view corsOrigin, const nlohmann::json &body)
 Writes body as a 200 application/json response with the CORS header.
 
template<typename Res >
void mm::api::sendError (Res *res, std::string_view status, std::string_view corsOrigin, std::string_view message)
 Writes a status response carrying a {"error": message} JSON body and the CORS header.
 
template<typename Res >
void mm::api::sendStatus (Res *res, std::string_view status, std::string_view corsOrigin)
 Writes a bare status response (no body) with the CORS header.