Mantis App v0.2.8
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 using json = nlohmann::json;
15
16 class TableUnit;
17 class SysTablesUnit;
18
22 class Router {
23 public:
24 explicit Router();
25
26 ~Router() = default;
27
29 bool initialize();
30
33 bool listen() const;
34
37 void close();
38
40 // void restart();
41
42 // Manage routes
43 [[nodiscard]]
48 json addRoute(const std::string &table);
49
54 json updateRoute(const json &table_data = json::object());
55
59 json updateRouteCache(const json &table_data = json::object());
60
64 json removeRoute(const json &table_data = json::object());
65
66 const std::string __class_name__ = "mantis::Router";
67
68 private:
73 bool generateFileServingApi() const;
74
79 bool generateTableCrudApis();
80
81 bool generateMiscEndpoints() const;
82
87 bool generateAdminCrudApis() const;
88
89 std::shared_ptr<TableUnit> m_adminTable;
90 std::shared_ptr<SysTablesUnit> m_tableRoutes;
91 std::vector<std::shared_ptr<TableUnit> > m_routes = {};
92
93 public:
94 std::vector<json> adminTableFields = {};
95 };
96}
97
98#endif // MANTIS_SERVER_H
Router class allows for managing routes as well as acting as a top-wrapper on the HttpUnit.
Definition router.h:22
void close()
Definition router.cpp:77
json updateRouteCache(const json &table_data=json::object())
Definition router.cpp:198
const std::string __class_name__
Definition router.h:66
bool listen() const
Definition router.cpp:62
json updateRoute(const json &table_data=json::object())
Definition router.cpp:136
std::vector< json > adminTableFields
Definition router.h:94
~Router()=default
json removeRoute(const json &table_data=json::object())
Definition router.cpp:225
json addRoute(const std::string &table)
Restart the HTTP server.
Definition router.cpp:82
Router()
Definition router.cpp:23
bool initialize()
Initialize the router instance creating tables and admin routes.
Definition router.cpp:43
nlohmann::json json
Definition mantis.h:35
router.h
Definition app.h:31
nlohmann::json json
Shorten JSON namespace.
Definition crud.h:14