1
0
mirror of https://github.com/s00500/ESPUI.git synced 2024-11-22 14:20:53 +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

@ -1436,6 +1436,10 @@ void ESPUIClass::begin(const char* _title, const char* username, const char* pas
}
});
if (onCreateServerCallback) {
onCreateServerCallback(server);
}
server->begin();
#if defined(DEBUG_ESPUI)

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,
@ -246,6 +251,8 @@ protected:
AsyncWebServer* server;
AsyncWebSocket* ws;
onCreateServerCallback_t onCreateServerCallback = nullptr;
const char* basicAuthUsername = nullptr;
const char* basicAuthPassword = nullptr;
bool basicAuth = true;