Enhance AsyncCallbackJsonWebHandler with regex support#299
Enhance AsyncCallbackJsonWebHandler with regex support#299nicola02nb wants to merge 7 commits intoESP32Async:mainfrom
Conversation
Added regex support for URI handling in AsyncCallbackJsonWebHandler.
|
@nicola02nb : is your pr a work in progress ? I have moved the pr to draft since I am not sure. thanks for the contribution this is a good idea ! also could you please add an example of you have time ? |
I made those edits on my local project and worked so I thought to make a pr for that(I copy pasted the code from
No prob
Happy to hear that
Yeah, give me some time and I'll do that |
|
Thanks 👍 |
|
@mathieucarbou should be all done, please let me know if everithing is ok |
|
@nicola02nb thanks! I will talk to the team about this one. I finished a refactoring of the Json support in #301, following isseu #300 .
~~There is already a mechanism in place (see the doc) to support variables in paths. ~~
@willmmiles @me-no-dev : we need to talk about this. |
Update: Ah! Looking again at the code I see that the regex check is done in So yes that's good no worry! I forgot how regex was wired ;-) Let's wait for the refactoring into #301 to be merged first and then rebase these changes. You should be also able to update you example to use the new way of adding a json handler, just by using: server.on("^\\/page\\/(\\d+)$", HTTP_POST, [](AsyncWebServerRequest *request, JsonVariant &json) {
// handle the json POST/PUT request...
String number = request->pathArg(0);
}); |
Great, so I can just close this pr and wait, right? |
No no! I see that your branch is opened to maintainers to either you or us will be able to do these updates. |
Okok, my bad sorry, thought you will get it work directly in #301
Of course :) |
|
@nicola02nb : FYI we discussed this PR with the team and we will implement it but another way. To avoid the code duplication, we will introduce a This way, the logic will be at one place and applied to all handlers. even those serving static content and templates. You can keep this PR opened: either we will build on it, or at least refer to it. Thanks! |
|
Ok cool, I'll keep it open so you can work on it if you want... are you going to add it soon? Just to have an idea.... |
|
Yes, probably this week or next week. |
|
@nicola02nb : FYI I have raised a work in progress PR which is compiling but not tested yet and no regex examples yet.
You do not need any code change, still need to set the macro PR: #304 |
Just tried on my project and works fine with no issue atm
That's clever didn't know about that, thanks |
|
Closing in favour of #304 |
Added regex support for URI handling in
AsyncCallbackJsonWebHandlerlike inAsyncCallbackWebHandler.With this you can do something like that
And also have the already parsed json body