Central HTTP router and schema cache for a MantisBase instance.
More...
#include <router.h>
|
| | MbRouter (const MantisBase &app) |
| | ~MbRouter () |
| bool | init () |
| bool | listen () |
| void | close () |
| MbSSEMgr & | sseMgr () const |
| void | Get (const std::string &path, const MbHandlerFn &handler, const MbMiddlewares &middlewares={}) |
| void | Post (const std::string &path, const MbHandlerFn &handler, const MbMiddlewares &middlewares={}) |
| void | Patch (const std::string &path, const MbHandlerFn &handler, const MbMiddlewares &middlewares={}) |
| void | Put (const std::string &path, const MbHandlerFn &handler, const MbMiddlewares &middlewares={}) |
| void | Delete (const std::string &path, const MbHandlerFn &handler, const MbMiddlewares &middlewares={}) |
| void | redirect (const std::string &initialPath, const std::string &destinationPath, int redirectStatus=302, const std::vector< std::string > &constraints={"GET"}) const |
| const json & | schemaCache (const std::string &table_name) const |
| bool | hasSchemaCache (const std::string &table_name) const |
| MbEntity | schemaCacheEntity (const std::string &table_name) const |
| void | addSchemaCache (const nlohmann::json &entity_schema) const |
| void | updateSchemaCache (const std::string &old_entity_name, const json &new_schema) const |
| void | removeSchemaCache (const std::string &entity_name) const |
| void | addSchemaCacheLocked (const nlohmann::json &entity_schema) const |
| void | removeSchemaCacheLocked (const std::string &entity_name) const |
| bool | isRunning () const |
| void | reloadCorsOrigins () const |
| void | applyCorsHeaders (const drogon::HttpRequestPtr &req, const drogon::HttpResponsePtr &resp) const |
| const std::vector< MbMiddlewareFn > & | preRoutingMiddlewares () const |
| | MbAppMixin (const MantisBase &app) |
| | Constrictor for instantiating this interface.
|
| | MbAppMixin (MbAppMixin &&)=default |
| MbAppMixin & | operator= (MbAppMixin &&)=delete |
| | MbAppMixin (const MbAppMixin &)=default |
| MbAppMixin & | operator= (const MbAppMixin &)=delete |
| const MantisBase & | mbApp () const |
| | Application that owns this service or request context.
|
| const MbLogger & | logger () const |
Central HTTP router and schema cache for a MantisBase instance.
◆ MbRouter()
◆ ~MbRouter()
| mb::MbRouter::~MbRouter |
( |
| ) |
|
◆ addSchemaCache()
| void mb::MbRouter::addSchemaCache |
( |
const nlohmann::json & | entity_schema | ) |
const |
◆ addSchemaCacheLocked()
| void mb::MbRouter::addSchemaCacheLocked |
( |
const nlohmann::json & | entity_schema | ) |
const |
Like addSchemaCache but assumes the caller already holds the schema mutex.
◆ applyCorsHeaders()
| void mb::MbRouter::applyCorsHeaders |
( |
const drogon::HttpRequestPtr & | req, |
|
|
const drogon::HttpResponsePtr & | resp ) const |
Add CORS headers when the request Origin is in the allowlist.
◆ close()
| void mb::MbRouter::close |
( |
| ) |
|
Stop the HTTP server and realtime subsystems.
◆ Delete()
| void mb::MbRouter::Delete |
( |
const std::string & | path, |
|
|
const MbHandlerFn & | handler, |
|
|
const MbMiddlewares & | middlewares = {} ) |
◆ Get()
| void mb::MbRouter::Get |
( |
const std::string & | path, |
|
|
const MbHandlerFn & | handler, |
|
|
const MbMiddlewares & | middlewares = {} ) |
◆ hasSchemaCache()
| bool mb::MbRouter::hasSchemaCache |
( |
const std::string & | table_name | ) |
const |
|
nodiscard |
◆ init()
| bool mb::MbRouter::init |
( |
| ) |
|
Initialize Drogon, register routes, and prepare the schema cache.
◆ isRunning()
| bool mb::MbRouter::isRunning |
( |
| ) |
const |
|
nodiscard |
◆ listen()
| bool mb::MbRouter::listen |
( |
| ) |
|
Start listening on the configured host/port.
◆ Patch()
| void mb::MbRouter::Patch |
( |
const std::string & | path, |
|
|
const MbHandlerFn & | handler, |
|
|
const MbMiddlewares & | middlewares = {} ) |
◆ Post()
| void mb::MbRouter::Post |
( |
const std::string & | path, |
|
|
const MbHandlerFn & | handler, |
|
|
const MbMiddlewares & | middlewares = {} ) |
◆ preRoutingMiddlewares()
| const std::vector< MbMiddlewareFn > & mb::MbRouter::preRoutingMiddlewares |
( |
| ) |
const |
|
inline |
◆ Put()
| void mb::MbRouter::Put |
( |
const std::string & | path, |
|
|
const MbHandlerFn & | handler, |
|
|
const MbMiddlewares & | middlewares = {} ) |
◆ redirect()
| void mb::MbRouter::redirect |
( |
const std::string & | initialPath, |
|
|
const std::string & | destinationPath, |
|
|
int | redirectStatus = 302, |
|
|
const std::vector< std::string > & | constraints = {"GET"} ) const |
Create a redirect path with the given status code for redirect
- Parameters
-
| initialPath | Existing path to be redirected elsewhere (/some/old/path) |
| destinationPath | Destination path, either relative (/some/path) or absolute URL (http(s)://some.domain/path) |
| redirectStatus | The redirect status, by default 302 Found. Use 301 for permanent moves, 302/303/307/308 for temporary ones. |
| constraints | Array of HTTP methods allowed for this redirect. Defaults to {"GET"} (GET-only). Pass an empty array to allow all methods. |
◆ reloadCorsOrigins()
| void mb::MbRouter::reloadCorsOrigins |
( |
| ) |
const |
Reload allowed CORS origins from settings and MB_CORS_ORIGINS.
◆ removeSchemaCache()
| void mb::MbRouter::removeSchemaCache |
( |
const std::string & | entity_name | ) |
const |
◆ removeSchemaCacheLocked()
| void mb::MbRouter::removeSchemaCacheLocked |
( |
const std::string & | entity_name | ) |
const |
◆ schemaCache()
| const json & mb::MbRouter::schemaCache |
( |
const std::string & | table_name | ) |
const |
- Returns
- Cached entity schema JSON for table_name.
◆ schemaCacheEntity()
| MbEntity mb::MbRouter::schemaCacheEntity |
( |
const std::string & | table_name | ) |
const |
- Returns
- Cached MbEntity built from the schema cache entry.
◆ sseMgr()
| MbSSEMgr & mb::MbRouter::sseMgr |
( |
| ) |
const |
- Returns
- SSE/WebSocket realtime manager.
◆ updateSchemaCache()
| void mb::MbRouter::updateSchemaCache |
( |
const std::string & | old_entity_name, |
|
|
const json & | new_schema ) const |
The documentation for this class was generated from the following files: