I want to send all paths that start with "/robot" to a certain handler using ESP8266WebServer.h. I tried a few variations:
server.on ( "/robot", handleDirection );
server.on ( "/robot/", handleDirection );
server.on ( "/robot/*", handleDirection );
But in each case, it only listens for the exact path (including the * for that one).
Does this library just not support wildcard paths? Or am I missing how to do it?
This is very easy in OO way
class MyHandler : public RequestHandler {
bool canHandle(HTTPMethod method, String uri) {
return uri.startsWith( "/robot" );
}
bool handle(ESP8266WebServer& server, HTTPMethod requestMethod, String requestUri) {
doRobot( requestUri );
server.send(200, "text/plain", "Yes!!");
return true;
}
} myHandler;
...
server.addHandler( &myHandler );
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With