I'm following the examples for ESP32:
AsyncWebServer _server(80);
_server.on("/", HTTP_GET, [](AsyncWebServerRequest *request)
{
request->send(SPIFFS, "/index.html", String(), false);
});
_server.on("/css/index.css", HTTP_GET, [](AsyncWebServerRequest *request){
request->send(SPIFFS, "/css/index.css", "text/css");
});
_server.onNotFound([](AsyncWebServerRequest *request){
request->send(404);
});
_server.begin();
With this approach I have to know in advance each file I store in the SPIFFS and add a handler for each one.
Is there a more elegant way to automatically serve any file that exists in the flash?