куча мелких изменений в вебе

This commit is contained in:
2024-11-07 18:07:06 +03:00
parent 4a293e10f6
commit fae7a2ffc8
5 changed files with 161 additions and 47 deletions

View File

@@ -162,7 +162,7 @@ public:
}));
s.resources.emplace_back(std::make_unique<http::resource::GenericResource>("/logout", [this](const auto& req, auto& rep) {
if (req.method == "GET") {
http::server::httpRedirect(rep, "/");
http::server::httpRedirect(rep, "/login");
rep.headers.push_back({.name = "Set-Cookie", .value = http::auth::jwt::EMPTY_AUTH_COOKIE});
} else {
http::server::stockReply(http::server::bad_request, rep);

View File

@@ -25,17 +25,12 @@ static void loadFile(const std::string& path, std::vector<char>& content) {
http::resource::BasicResource::BasicResource(std::string path): path(std::move(path)) {}
http::resource::StaticFileFactory::StaticFileDef::StaticFileDef(std::string path, server::mime_types::Mime type, bool allowCache): path(std::move(path)), type(type), allowCache(allowCache) {
#ifdef USE_DEBUG
if (allowCache) {
BOOST_LOG_TRIVIAL(info) << "Load static file " << this->path;
loadFile(this->path, this->content);
} else {
BOOST_LOG_TRIVIAL(info) << "Skip loading static file " << this->path;
}
#else
BOOST_LOG_TRIVIAL(info) << "Load static file " << this->path;
loadFile(this->path, this->content);
#endif
}
http::resource::StaticFileFactory::StaticFileDef::~StaticFileDef() = default;
@@ -48,7 +43,6 @@ void http::resource::StaticFileFactory::registerFile(const std::string &path, se
void http::resource::StaticFileFactory::serve(const std::string &path, server::Reply &rep) {
for (auto& f: this->files) {
if (f.path == path) {
#ifdef USE_DEBUG
if (f.allowCache) {
rep.content.clear();
rep.content.insert(rep.content.end(), f.content.begin(), f.content.end());
@@ -56,10 +50,6 @@ void http::resource::StaticFileFactory::serve(const std::string &path, server::R
BOOST_LOG_TRIVIAL(debug) << "Reload file " << path << " (http path: " << path << ")";
loadFile(f.path, rep.content);
}
#else
rep.content.clear();
rep.content.insert(rep.content.end(), f.content.begin(), f.content.end());
#endif
rep.status = server::ok;
// rep.headers.clear();
rep.headers.push_back({.name = "Content-Type", .value = server::mime_types::toString(f.type)});

View File

@@ -166,8 +166,6 @@ void api_driver::ApiDriver::resetPacketStatistics() const {
}
std::string api_driver::ApiDriver::loadSettings() const {
// constexpr auto* UNKNOWN = "\"?\"";
modulator_settings modSettings{};
CP_GetModulatorSettings(sid, modSettings);
uint32_t modulatorModcod;