Motion Master 6.0.0-alpha.86
Next-generation motion control software
Loading...
Searching...
No Matches
mm::api::Router Class Reference

Registers routes whose handlers run off the event loop. More...

#include <router.h>

Public Member Functions

 Router (uWS::SSLApp &app, uWS::Loop *loop, BS::light_thread_pool &pool, const std::atomic< bool > &stopping, std::string_view corsOrigin)
 
void get (const std::string &pattern, Handler handler)
 Registers handler for GET pattern. Path parameters are :name as in uWS.
 
void post (const std::string &pattern, Handler handler)
 Registers handler for POST pattern; the body is accumulated before dispatch.
 
void put (const std::string &pattern, Handler handler)
 Registers handler for PUT pattern; the body is accumulated before dispatch.
 
void del (const std::string &pattern, Handler handler)
 Registers handler for DELETE pattern.
 

Detailed Description

Registers routes whose handlers run off the event loop.

Holds no ownership: the app, loop, pool and CORS origin all outlive it, and it is used only during registration.

Constructor & Destructor Documentation

◆ Router()

mm::api::Router::Router ( uWS::SSLApp &  app,
uWS::Loop *  loop,
BS::light_thread_pool &  pool,
const std::atomic< bool > &  stopping,
std::string_view  corsOrigin 
)
inline
Parameters
appThe uWS app to register on.
loopThe app's loop; responses are written by deferring onto it.
poolWorkers the handlers run on. Must be drained before loop is closed.
stoppingSet once shutdown starts; while it is set, requests are answered 503 instead of being dispatched. See stopping_.
corsOriginValue for Access-Control-Allow-Origin; must outlive the server.

Member Function Documentation

◆ del()

void mm::api::Router::del ( const std::string &  pattern,
Handler  handler 
)
inline

Registers handler for DELETE pattern.

◆ get()

void mm::api::Router::get ( const std::string &  pattern,
Handler  handler 
)
inline

Registers handler for GET pattern. Path parameters are :name as in uWS.

◆ post()

void mm::api::Router::post ( const std::string &  pattern,
Handler  handler 
)
inline

Registers handler for POST pattern; the body is accumulated before dispatch.

◆ put()

void mm::api::Router::put ( const std::string &  pattern,
Handler  handler 
)
inline

Registers handler for PUT pattern; the body is accumulated before dispatch.


The documentation for this class was generated from the following files: