Add Uri with support for regexUri and globUri (#3441)

* Add Uri with support for staticUri, regexUri and globUri

* Add newline to end of files

* Update example

* Suppress gcc warnings (unused params)
This commit is contained in:
Bob
2020-01-20 14:21:01 +01:00
committed by Me No Dev
parent c09ec5bd3d
commit cfe8526ec8
8 changed files with 182 additions and 54 deletions

View File

@ -3,6 +3,9 @@
#include <WebServer.h>
#include <ESPmDNS.h>
#include <uri/UriBraces.h>
#include <uri/UriRegex.h>
const char *ssid = "........";
const char *password = "........";
@ -33,12 +36,12 @@ void setup(void) {
server.send(200, "text/plain", "hello from esp32!");
});
server.on("/users/{}", []() {
server.on(UriBraces("/users/{}"), []() {
String user = server.pathArg(0);
server.send(200, "text/plain", "User: '" + user + "'");
});
server.on("/users/{}/devices/{}", []() {
server.on(UriRegex("^\\/users\\/([0-9]+)\\/devices\\/([0-9]+)$"), []() {
String user = server.pathArg(0);
String device = server.pathArg(1);
server.send(200, "text/plain", "User: '" + user + "' and Device: '" + device + "'");