diff --git a/src/patrix/http.cpp b/src/patrix/http.cpp index c1af68a..7e0340b 100644 --- a/src/patrix/http.cpp +++ b/src/patrix/http.cpp @@ -5,15 +5,18 @@ AsyncWebServer server(80); -void httpNotFound(AsyncWebServerRequest *request) { - if (request->method() == HTTP_OPTIONS) { +void httpNotFound(AsyncWebServerRequest* request) { + const String path = request->url(); + if (path.endsWith("/") && path.length() > 1) { + request->redirect(path.substring(0, path.length() - 1)); + } else if (request->method() == HTTP_OPTIONS) { request->send(200); } else { request->send(404, "text/plain", "not found"); } } -void httpRestart([[maybe_unused]] AsyncWebServerRequest *request) { +void httpRestart([[maybe_unused]] AsyncWebServerRequest* request) { systemRequestRestart(); request->send(200, "application/json", "true"); } @@ -30,4 +33,4 @@ void httpSetup() { void httpStop() { server.end(); -} \ No newline at end of file +}