mirror of
https://gitlab.com/wirelos/sprocket-lib.git
synced 2025-12-15 13:08:21 +01:00
31 lines
894 B
C++
31 lines
894 B
C++
#ifndef __WEB_SERVER_PLUGIN__
|
|
#define __WEB_SERVER_PLUGIN__
|
|
|
|
#include <FS.h>
|
|
#include <ESPAsyncWebServer.h>
|
|
#include "TaskSchedulerDeclarations.h"
|
|
#include "Plugin.h"
|
|
#include <plugins/WebServerConfig.h>
|
|
|
|
using namespace std;
|
|
using namespace std::placeholders;
|
|
|
|
class WebServerPlugin : public Plugin {
|
|
private:
|
|
WebServerConfig config;
|
|
AsyncWebServer* server;
|
|
public:
|
|
WebServerPlugin(WebServerConfig cfg, AsyncWebServer* webServer){
|
|
config = cfg;
|
|
server = webServer;
|
|
}
|
|
void activate(Scheduler* userScheduler){
|
|
server->serveStatic(config.contextPath, SPIFFS, config.docRoot).setDefaultFile(config.defaultFile);
|
|
// TODO add auth if configured
|
|
// server->setAuthentication("user", "pass");
|
|
server->begin();
|
|
Serial.println("WebServer activated");
|
|
}
|
|
};
|
|
|
|
#endif |