Mantis App v0.1.13
Loading...
Searching...
No Matches
router.h
Go to the documentation of this file.
1
6#ifndef MANTIS_SERVER_H
7#define MANTIS_SERVER_H
8
9#include <memory>
10#include <vector>
11#include <nlohmann/json.hpp>
12
13namespace mantis
14{
15 using json = nlohmann::json;
16
17 class TableUnit;
18 class SysTablesUnit;
19
23 class Router
24 {
25 public:
26 explicit Router();
27 ~Router() = default;
28
30 bool initialize();
31
34 bool listen() const;
35
38 void close();
39
41 // void restart();
42
43 // Manage routes
44 [[nodiscard]]
49 json addRoute(const std::string& table);
50
55 json updateRoute(const json& table_data = json::object());
56
60 json updateRouteCache(const json& table_data = json::object());
61
65 json removeRoute(const json& table_data = json::object());
66
67 const std::string __class_name__ = "mantis::Router";
68 private:
69 bool generateTableCrudApis();
70 bool generateAdminCrudApis() const;
71
72 std::shared_ptr<TableUnit> m_adminTable;
73 std::shared_ptr<SysTablesUnit> m_tableRoutes;
74 std::vector<std::shared_ptr<TableUnit>> m_routes = {};
75 };
76}
77
78#endif // MANTIS_SERVER_H
Router class allows for managing routes as well as acting as a top-wrapper on the HttpUnit.
Definition router.h:24
void close()
Definition router.cpp:76
json updateRouteCache(const json &table_data=json::object())
Definition router.cpp:214
const std::string __class_name__
Definition router.h:67
bool listen() const
Definition router.cpp:56
json updateRoute(const json &table_data=json::object())
Definition router.cpp:143
~Router()=default
json removeRoute(const json &table_data=json::object())
Definition router.cpp:244
json addRoute(const std::string &table)
Restart the HTTP server.
Definition router.cpp:82
Router()
Definition router.cpp:22
bool initialize()
Initialize the router instance creating tables and admin routes.
Definition router.cpp:41
nlohmann::json json
Definition mantis.h:35
router.h
Definition app.h:30
nlohmann::json json
Shorten JSON namespace.
Definition crud.h:14