WebServer.on Question

Bootalito
Posts: 2
Joined: Tue Feb 27, 2018 4:45 am

WebServer.on Question

Postby Bootalito » Sun Sep 09, 2018 1:29 pm

There is a method is WebServer.h that I cannot find any documentation on.

Line 86:
void on(const String &uri, HTTPMethod method, THandlerFunction fn, THandlerFunction ufn);

This method is used in me-no-dev's "Webupdate" example which I'm trying to adapt to my project: (https://github.com/espressif/arduino-es ... /WebUpdate)

What is the difference between "THandlerFunction fn" & "THandlerFunction ufn"???

When I integrate this example into my project it works fine:

Code: Select all

HTTPserver.on("/update", HTTP_GET, []() { //Just presents the user with the update webpage for them to select a file
	if (!handleFileRead("/update.htm")) HTTPERROR();
});						
HTTPserver.on("/update", HTTP_POST, []() {
	//What is this for?
}, []() { //Handles the file upload and update.  It works fine
	RequestAuthentication();
	HTTPUpdateUpload();
});
(note that update.htm is a very simple page that does exactly what the page in the WebUpdate example does, except that it calls itself.)

But when I change the method to "void on(const String &uri, THandlerFunction handler);" it does not work, but seems like it should:

Code: Select all

HTTPserver.on("/update", HTTP_GET, []() {
	if (!handleFileRead("/update.htm")) HTTPERROR();
});						
HTTPserver.on("/update", HTTP_POST, []() { //Gets an unknown error from update. like its only calling it once
	RequestAuthentication();
	HTTPUpdateUpload();
});

Who is online

Users browsing this forum: No registered users and 51 guests