Mantis App v0.1.13
Loading...
Searching...
No Matches
settings.h
Go to the documentation of this file.
1//
2// Created by allan on 30/06/2025.
3//
4
5#ifndef SETTINGS_H
6#define SETTINGS_H
7
8#include <mantis/core/http.h>
9#include <nlohmann/json.hpp>
10
11namespace mantis
12{
13 using json = nlohmann::json;
14
15 class MantisApp;
16
21 {
22 public:
23 SettingsUnit() = default;
24
29 bool setupRoutes();
30
34 void migrate();
35
46 bool hasAccess([[maybe_unused]] const Request& req, Response& res, Context& ctx);
47
48 // Getter sections
54 json& configs();
55
56 private:
62 json initSettingsConfig();
63
67 void setupConfigRoutes();
68
69 // Cache settings config on create/read/update cycles to reduce database reads
70 // may not be that significant though...!
71 json m_configs;
72
73 const std::string __class_name__ = "mantis::SettingsUnit";
74 };
75} // mantis
76
77#endif //SETTINGS_H
Definition http.h:59
Manages application settings.
Definition settings.h:21
void migrate()
Initialize migration, create base data for setting fields.
Definition settings.cpp:37
bool setupRoutes()
Initialize and set up routes for fetching settings data.
Definition settings.cpp:19
json & configs()
Get the current config data instance.
Definition settings.cpp:187
bool hasAccess(const Request &req, Response &res, Context &ctx)
Evaluate if request is authenticated and has permission to access this route.
Definition settings.cpp:77
Wrapper around http-lib to add middleware support and context values to be passed from middlewares up...
nlohmann::json json
Definition mantis.h:35
router.h
Definition app.h:30
nlohmann::json json
Shorten JSON namespace.
Definition crud.h:14
httplib::Response Response
‍Shorthand for httplib::Response
Definition http.h:121
httplib::Request Request
‍Shorthand for httplib::Request
Definition http.h:118