1
0
mirror of https://github.com/s00500/ESPUI.git synced 2024-12-23 11:00:48 +00:00

Add onCreateServerCallback hook

This commit is contained in:
Nikola Kirov 2023-12-09 08:56:52 +02:00
parent 31911b3969
commit 656dab6e6a
2 changed files with 14 additions and 3 deletions

View File

@ -1435,6 +1435,10 @@ void ESPUIClass::begin(const char* _title, const char* username, const char* pas
request->send(404);
}
});
if (onCreateServerCallback) {
onCreateServerCallback(server);
}
server->begin();

View File

@ -28,9 +28,7 @@
#else
#include <ArduinoOTA.h>
#include <ESP8266WiFi.h>
#include <ESP8266mDNS.h>
#include <ESPAsyncTCP.h>
#include <Hash.h>
@ -108,6 +106,13 @@ public:
bool auto_update_values = false;
void setVerbosity(Verbosity verbosity);
typedef std::function<void(AsyncWebServer*)> onCreateServerCallback_t;
void onCreateServerCallbackSet(onCreateServerCallback_t callback)
{
onCreateServerCallback = callback;
}
void begin(const char* _title, const char* username = nullptr, const char* password = nullptr,
uint16_t port = 80); // Setup server and page in Memorymode
void beginSPIFFS(const char* _title, const char* username = nullptr, const char* password = nullptr,
@ -245,7 +250,9 @@ protected:
AsyncWebServer* server;
AsyncWebSocket* ws;
onCreateServerCallback_t onCreateServerCallback = nullptr;
const char* basicAuthUsername = nullptr;
const char* basicAuthPassword = nullptr;
bool basicAuth = true;