I'm having a problem handling requests on an ESP that acts as WebServer. Basically this code:
#include <WebServer.h> //using this library
...
webServer.on("/api/:userId/lights", HTTP_GET, [this]() { handle_GetState(); });
webServer.on("/api/:userId/lights/:num", HTTP_GET, [this]() { handle_GetState(); });
webServer.on("/api/:userId/lights/:num/state", HTTP_PUT, [this]() { handle_PutState(); });
webServer.on("/", HTTP_GET, [this]() { handle_root(); });
webServer.on("/debug/clip.html", HTTP_GET, [this]() { handle_clip(); });
webServer.onNotFound( [this]() { handle_CORSPreflight(); });
is supposed to handle dynamic path parameters but when making a request (example: /api/USERXXX/lights) it's always handled by onNotFound function.
I've tried to replace ':userId' with '{}', '{userId}', '<userId>', but nothing seems to work. Obviously when calling http://192.168.XXX.XXX/api/:userId/lights the webserver retrieves the right response so the path parameter notation is not recognized.
Anyone knows which is the right way to do it?