i have this function that i use with esp8266http webeserver. Now i have esp32asyncWebserver and it seems really advanced to my knowledge. Will someone please help or re-write this function to work with ESP32AsyncWebServer??
server.onNotFound([] {if (loadFromSpiffs(server.uri())) return;}); //Set server all paths are not found so we can handle as per URI
bool loadFromSpiffs(String path) {
String dataType = "text/plain";
if (path.endsWith("/")) path += "index.htm";
if (path.endsWith(".src")) path = path.substring(0, path.lastIndexOf("."));
else if (path.endsWith(".html")) dataType = "text/html";
else if (path.endsWith(".htm")) dataType = "text/html";
else if (path.endsWith(".css")) dataType = "text/css";
else if (path.endsWith(".js")) dataType = "application/javascript";
else if (path.endsWith(".png")) dataType = "image/png";
else if (path.endsWith(".gif")) dataType = "image/gif";
else if (path.endsWith(".jpg")) dataType = "image/jpeg";
else if (path.endsWith(".ico")) dataType = "image/x-icon";
else if (path.endsWith(".xml")) dataType = "text/xml";
else if (path.endsWith(".pdf")) dataType = "application/pdf";
else if (path.endsWith(".zip")) dataType = "application/zip";
File dataFile = SPIFFS.open(path.c_str(), "r");
if (server.hasArg("download")) dataType = "application/octet-stream";
if (server.streamFile(dataFile, dataType) != dataFile.size()) {
}
dataFile.close();
return true;
}```
i have been trying to use this as a reference, ESPAsyncWebServer/ESP_AsyncFSBrowser.ino at master · me-no-dev/ESPAsyncWebServer · GitHub
but i have not had a lot of luck