Skip to content

Commit f6bc957

Browse files
Update example
1 parent d0e64a7 commit f6bc957

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

libraries/WebServer/examples/PathArgServer/PathArgServer.ino

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
#include <WebServer.h>
44
#include <ESPmDNS.h>
55

6+
#include <uri/UriBraces.h>
7+
#include <uri/UriRegex.h>
8+
69
const char *ssid = "........";
710
const char *password = "........";
811

@@ -33,12 +36,12 @@ void setup(void) {
3336
server.send(200, "text/plain", "hello from esp32!");
3437
});
3538

36-
server.on("/users/{}", []() {
39+
server.on(UriBraces("/users/{}"), []() {
3740
String user = server.pathArg(0);
3841
server.send(200, "text/plain", "User: '" + user + "'");
3942
});
4043

41-
server.on("/users/{}/devices/{}", []() {
44+
server.on(UriRegex("^\\/users\\/([0-9]+)\\/devices\\/([0-9]+)$"), []() {
4245
String user = server.pathArg(0);
4346
String device = server.pathArg(1);
4447
server.send(200, "text/plain", "User: '" + user + "' and Device: '" + device + "'");

0 commit comments

Comments
 (0)