1
0
mirror of https://github.com/s00500/ESPUI.git synced 2025-06-14 02:30:41 +00:00

Merge pull request #197 from ncmreynolds/main

Add captive portal functionality, update examples and documentation, resolves #134
This commit is contained in:
2022-09-21 10:06:57 +02:00
committed by GitHub
5 changed files with 34 additions and 3 deletions

View File

@ -1351,7 +1351,16 @@ void ESPUIClass::beginLITTLEFS(const char* _title, const char* username, const c
request->send(200, "text/plain", String(ESP.getFreeHeap()) + " In LITTLEFS mode");
});
server->onNotFound([](AsyncWebServerRequest* request) { request->send(404); });
server->onNotFound([this](AsyncWebServerRequest* request) {
if(captivePortal)
{
request->redirect("/");
}
else
{
request->send(404);
}
});
server->begin();
@ -1496,7 +1505,16 @@ void ESPUIClass::begin(const char* _title, const char* username, const char* pas
request->send(200, "text/plain", String(ESP.getFreeHeap()) + " In Memorymode");
});
server->onNotFound([](AsyncWebServerRequest* request) { request->send(404); });
server->onNotFound([this](AsyncWebServerRequest* request) {
if(captivePortal)
{
request->redirect("/");
}
else
{
request->send(404);
}
});
server->begin();

View File

@ -236,6 +236,7 @@ public:
unsigned int jsonUpdateDocumentSize;
unsigned int jsonInitialDocumentSize;
bool sliderContinuous;
bool captivePortal = true;
void setVerbosity(Verbosity verbosity);
void begin(const char* _title, const char* username = nullptr, const char* password = nullptr,