esp32-sk6812/include/WebServer.h

48 lines
1.5 KiB
C++

#pragma once
#include <HTTPRequest.hpp>
#include <HTTPResponse.hpp>
#include <HTTPServer.hpp>
#include "ChallengeResponse.h"
class Fader;
class AnimationController;
class WebServer
{
public:
bool start(void);
void setFader(Fader *fader) { m_fader = fader;}
void setAnimationController(AnimationController *controller) { m_animController = controller;}
static WebServer &instance(void)
{
static WebServer theInstance;
return theInstance;
}
private:
httpsserver::HTTPServer *m_server;
ChallengeResponse m_cr;
Fader *m_fader;
AnimationController *m_animController;
WebServer(void);
static void serverTask(void *arg);
static bool serveFile(String filename, httpsserver::HTTPResponse *res);
// handlers
static void handleRoot(httpsserver::HTTPRequest *req, httpsserver::HTTPResponse *res);
static void handleColor(httpsserver::HTTPRequest *req, httpsserver::HTTPResponse *res);
static void handleSetAnim(httpsserver::HTTPRequest *req, httpsserver::HTTPResponse *res);
static void handleChallenge(httpsserver::HTTPRequest *req, httpsserver::HTTPResponse *res);
static void handleAuthTest(httpsserver::HTTPRequest *req, httpsserver::HTTPResponse *res);
static void handleUpdate(httpsserver::HTTPRequest *req, httpsserver::HTTPResponse *res);
static void handleStatic(httpsserver::HTTPRequest *req, httpsserver::HTTPResponse *res);
};