Skip to content

Commit 330da10

Browse files
committed
feat: allow wildcard endpoint
1 parent 96c62c3 commit 330da10

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

src/AsyncJson.h

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

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

206212
if ( !request->contentType().equalsIgnoreCase(JSON_MIMETYPE) )
207213
return false;

0 commit comments

Comments
 (0)