Use template in rendering

This commit is contained in:
Jaakko Haakana 2025-07-08 07:56:05 +03:00
parent 5ac816b80f
commit 376b2c6faf
6 changed files with 527 additions and 215 deletions

View file

@ -187,9 +187,15 @@ void init_webserver() {
// Route for going to settings web page
server.on("/settings", HTTP_GET, [](AsyncWebServerRequest* request) {
if (WEBSERVER_AUTH_REQUIRED && !request->authenticate(http_username, http_password))
if (WEBSERVER_AUTH_REQUIRED && !request->authenticate(http_username, http_password)) {
return request->requestAuthentication();
request->send(200, "text/html", index_html, settings_processor);
}
// Using make_shared to ensure lifetime for the settings object during send() lambda execution
auto settings = std::make_shared<BatteryEmulatorSettingsStore>(true);
request->send(200, "text/html", settings_html,
[settings](const String& content) { return settings_processor(content, *settings); });
});
// Route for going to advanced battery info web page