refactor: some changes

This commit is contained in:
Yurii
2024-11-15 00:25:41 +03:00
parent 0d71a674b6
commit 19feb85230
7 changed files with 62 additions and 15 deletions

View File

@@ -189,6 +189,11 @@ protected:
return true;
})->setBeforeUpgradeCallback([](UpgradeHandler::UpgradeType type) -> bool {
if (vars.states.restarting) {
return false;
}
vars.states.upgrading = true;
return true;
})->setAfterUpgradeCallback([this](const UpgradeHandler::UpgradeResult& fwResult, const UpgradeHandler::UpgradeResult& fsResult) {
unsigned short status = 200;
@@ -209,6 +214,8 @@ protected:
response.concat(fsResult.error);
response.concat(F("\"}}"));
this->webServer->send(status, F("application/json"), response);
vars.states.upgrading = false;
});
this->webServer->addHandler(upgradeHandler);
@@ -247,6 +254,10 @@ protected:
}
}
if (vars.states.restarting) {
return this->webServer->send(503);
}
const String& plain = this->webServer->arg(0);
Log.straceln(FPSTR(L_PORTAL_WEBSERVER), F("Request /api/backup/restore %d bytes: %s"), plain.length(), plain.c_str());
@@ -337,6 +348,10 @@ protected:
return this->webServer->send(401);
}
}
if (vars.states.restarting) {
return this->webServer->send(503);
}
const String& plain = this->webServer->arg(0);
Log.straceln(FPSTR(L_PORTAL_WEBSERVER), F("Request /api/network/settings %d bytes: %s"), plain.length(), plain.c_str());
@@ -452,6 +467,10 @@ protected:
return this->webServer->send(401);
}
}
if (vars.states.restarting) {
return this->webServer->send(503);
}
const String& plain = this->webServer->arg(0);
Log.straceln(FPSTR(L_PORTAL_WEBSERVER), F("Request /api/settings %d bytes: %s"), plain.length(), plain.c_str());
@@ -557,6 +576,10 @@ protected:
return this->webServer->send(401);
}
}
if (vars.states.restarting) {
return this->webServer->send(503);
}
#ifdef ARDUINO_ARCH_ESP8266
if (!this->webServer->hasArg(F("id")) || this->webServer->args() != 1) {