25 lines
712 B
C++
25 lines
712 B
C++
|
#include <ESPMegaWebServer.hpp>
|
||
|
|
||
|
ESPMegaWebServer::ESPMegaWebServer(uint16_t port, ESPMegaIoT *iot) {
|
||
|
this->port = port;
|
||
|
this->iot = iot;
|
||
|
this->server = new AsyncWebServer(port);
|
||
|
}
|
||
|
|
||
|
ESPMegaWebServer::~ESPMegaWebServer() {
|
||
|
delete this->server;
|
||
|
}
|
||
|
|
||
|
void ESPMegaWebServer::begin() {
|
||
|
this->server->begin();
|
||
|
auto bindedDashboardHandler = std::bind(&ESPMegaWebServer::dashboardHandler, this, std::placeholders::_1);
|
||
|
this->server->on("/", HTTP_GET, bindedDashboardHandler);
|
||
|
}
|
||
|
|
||
|
void ESPMegaWebServer::loop() {
|
||
|
// AsyncWebServer doesn't have a loop function
|
||
|
}
|
||
|
|
||
|
void ESPMegaWebServer::dashboardHandler(AsyncWebServerRequest *request) {
|
||
|
request->send(200, "text/plain", "Hello World!");
|
||
|
}
|