Cosmic Mac wrote:And you can take advantage of C++ default parameters to simplify the code:Code: Select allserver.on("/", handleRoot);
serverExt.on("/", handleRootExt);
void handleRootExt() {
handleRoot(true)
}
void handleRoot(boolean blIsExtAccess = false) {
String stData = "Hello there";
if (blIsExtAccess == false) {
server.send(200, "text/html", stData);
} else {
serverExt.send(200, "text/html", stData);
}
}
Another way would be to redirect Ext requests to the main server:Code: Select allserverExt.on("/", []() {
serverExt.sendHeader("Location", String("http://") + toStringIp(serverExt.client().localIP()), true);
serverExt.send(302, "text/plain", "");
serverExt.client().stop();
});
server.on("/", []() {
String stData = "Hello there";
server.send(200, "text/html", stData);
});
Untested...
Thank you for your approach, I would use your 1st one, but I got error "'handleRoot' was not declared in this scope".
Just a note that my handleRoot function is in another Tab/Sketch.
Any further ideas?