добавление включения/выключения логгирования через скрипт
This commit is contained in:
38
src/main.cpp
38
src/main.cpp
@@ -402,6 +402,7 @@ public:
|
||||
s.resources.emplace_back(std::make_unique<http::auth::AuthRequiredResource>("/api/firmwareUpdate", this->auth, http::auth::User::UPDATE_FIRMWARE, [this](const auto& req, auto& rep) {
|
||||
if (req.method != "PUT") {
|
||||
http::server::stockReply(http::server::bad_request, rep);
|
||||
return;
|
||||
}
|
||||
this->upgradeOrRebootRunning = true;
|
||||
onUploadFirmware(req);
|
||||
@@ -420,6 +421,7 @@ public:
|
||||
s.resources.emplace_back(std::make_unique<http::auth::AuthRequiredResource>("/api/doFirmwareUpgrade", this->auth, http::auth::User::UPDATE_FIRMWARE, [this](const auto& req, auto& rep) {
|
||||
if (req.method != "POST") {
|
||||
http::server::stockReply(http::server::bad_request, rep);
|
||||
return;
|
||||
}
|
||||
this->upgradeOrRebootRunning = true;
|
||||
doTerminalUpgrade();
|
||||
@@ -435,6 +437,42 @@ public:
|
||||
sf->serve(DEV_HTML, rep);
|
||||
}));
|
||||
|
||||
s.resources.emplace_back(std::make_unique<http::auth::AuthRequiredResource>("/dev/cpapicall", this->auth, http::auth::User::SUPERUSER, [this](const http::server::Request& req, auto& rep) {
|
||||
if (req.method != "POST") {
|
||||
http::server::stockReply(http::server::bad_request, rep);
|
||||
return;
|
||||
}
|
||||
if (req.url->params.find("f") == req.url->params.end()) {
|
||||
http::server::stockReply(http::server::bad_request, rep);
|
||||
return;
|
||||
}
|
||||
const auto func = req.url->params["f"];
|
||||
std::string result = R"({"status":"ok"})";
|
||||
if (func == "SetDmaDebug") {
|
||||
if (req.url->params.find("param") == req.url->params.end()) { http::server::stockReply(http::server::bad_request, rep); return; }
|
||||
if (req.url->params.find("value") == req.url->params.end()) { http::server::stockReply(http::server::bad_request, rep); return; }
|
||||
this->api->executeInApi([&](auto sid) {
|
||||
CP_SetDmaDebug(sid, req.url->params["param"].c_str(), req.url->params["value"]);
|
||||
});
|
||||
} else if (func == "GetDmaDebug") {
|
||||
if (req.url->params.find("param") == req.url->params.end()) { http::server::stockReply(http::server::bad_request, rep); return; }
|
||||
this->api->executeInApi([&](auto sid) {
|
||||
std::string tmp{};
|
||||
CP_GetDmaDebug(sid, req.url->params["param"].c_str(), &tmp);
|
||||
result = R"({"status":"ok","result":)";
|
||||
result += api_driver::buildEscapedString(tmp);
|
||||
result += "}";
|
||||
});
|
||||
} else {
|
||||
http::server::stockReply(http::server::not_implemented, rep);
|
||||
return;
|
||||
}
|
||||
|
||||
rep.status = http::server::ok;
|
||||
rep.headers.push_back({.name = "Content-Type", .value = toString(mime_types::json)});
|
||||
rep.content.insert(rep.content.end(), result.c_str(), result.c_str() + result.size());
|
||||
}));
|
||||
|
||||
// s.resources.emplace_back(std::make_unique<http::auth::AuthRequiredResource>("/dev/fetchParams", this->auth, http::auth::User::SUPERUSER, [this](const auto& req, auto& rep) {
|
||||
// rep.headers.push_back({.name = "Content-Type", .value = toString(mime_types::json)});
|
||||
// std::string result = R"({"status":"ok","fwsize":)";
|
||||
|
Reference in New Issue
Block a user