добавил запись настроек BucLnb

This commit is contained in:
2024-11-12 10:18:03 +03:00
parent cb9d412c8e
commit 857a01528b
4 changed files with 126 additions and 22 deletions

View File

@@ -217,8 +217,6 @@ public:
rep.content.insert(rep.content.end(), result.c_str(), result.c_str() + result.size());
}));
s.resources.emplace_back(std::make_unique<http::resource::GenericResource>("/api/set/qos", [this](const auto& req, auto& rep) {
if (req.method != "POST") {
http::server::stockReply(http::server::bad_request, rep);
@@ -236,7 +234,7 @@ public:
api->setQosSettings(pt);
std::string result = R"({"settings":)";
std::string result = R"({""status":"ok",settings":)";
result += api->loadSettings();
result += "}";
rep.content.insert(rep.content.end(), result.c_str(), result.c_str() + result.size());
@@ -247,6 +245,34 @@ public:
}
}));
s.resources.emplace_back(std::make_unique<http::resource::GenericResource>("/api/set/bucLnb", [this](const auto& req, auto& rep) {
if (req.method != "POST") {
http::server::stockReply(http::server::bad_request, rep);
}
rep.status = http::server::ok;
rep.headers.clear();
rep.headers.push_back({.name = "Content-Type", .value = toString(mime_types::json)});
try {
std::stringstream ss;
ss.str(std::string(req.payload.begin(), req.payload.end()));
boost::property_tree::ptree pt;
read_json(ss, pt);
api->setBucLnbSettings(pt);
std::string result = R"({"status":"ok","settings":)";
result += api->loadSettings();
result += "}";
rep.content.insert(rep.content.end(), result.c_str(), result.c_str() + result.size());
} catch (std::exception& e) {
BOOST_LOG_TRIVIAL(error) << "WebHandle(/api/set/bucLnb): Can't set settings: " << e.what();
const std::string result = R"({"status":"error"})";
rep.content.insert(rep.content.end(), result.c_str(), result.c_str() + result.size());
}
}));
}
~ServerResources() = default;