Skip to content

Commit 1e029ff

Browse files
committed
feat: allow wildcard endpoint
1 parent 7f1ec4f commit 1e029ff

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/AsyncJson.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,15 @@ class AsyncCallbackJsonWebHandler: public AsyncWebHandler {
201201

202202
if(!(_method & request->method()))
203203
return false;
204-
205-
if(_uri.length() && (_uri != request->url() && !request->url().startsWith(_uri+"/")))
206-
return false;
204+
205+
if (_uri.length() && _uri.endsWith("*")) {
206+
String uriTemplate = String(_uri);
207+
uriTemplate = uriTemplate.substring(0, uriTemplate.length() - 1);
208+
if (!request->url().startsWith(uriTemplate))
209+
return false;
210+
} else
211+
if(_uri.length() && (_uri != request->url() && !request->url().startsWith(_uri+"/")))
212+
return false;
207213

208214
if ( !request->contentType().equalsIgnoreCase(JSON_MIMETYPE) )
209215
return false;

0 commit comments

Comments
 (0)