Thêm phần 5. Monitoring và 6. System
Some checks failed
Test / test (push) Has been cancelled

This commit is contained in:
2026-06-25 16:00:18 +07:00
parent e0e864ea13
commit 77ea3cc361
27 changed files with 3564 additions and 31 deletions

View File

@@ -0,0 +1,35 @@
#include "server/api_server.hpp"
#include "util/http_util.hpp"
namespace lm {
void ApiServer::registerSettingsRoutes(httplib::Server& svr)
{
svr.Get("/api/settings", [this](const httplib::Request&, httplib::Response& res) {
HttpUtil::addCors(res);
res.set_header("Content-Type", "application/json; charset=utf-8");
res.body = settings_.get().dump();
});
svr.Put("/api/settings", [this](const httplib::Request& req, httplib::Response& res) {
HttpUtil::addCors(res);
nlohmann::json body;
try
{
body = nlohmann::json::parse(req.body);
}
catch (...)
{
return HttpUtil::jsonError(res, 400, "invalid JSON");
}
std::string err;
if (!settings_.put(body, err))
return HttpUtil::jsonError(res, 400, err);
res.set_header("Content-Type", "application/json; charset=utf-8");
res.body = settings_.get().dump();
});
}
} // namespace lm