2019-11-17 01:16:46 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <HTTPRequest.hpp>
|
|
|
|
#include <HTTPResponse.hpp>
|
|
|
|
#include <HTTPServer.hpp>
|
|
|
|
|
2019-11-25 22:45:01 +01:00
|
|
|
#include "ChallengeResponse.h"
|
|
|
|
|
2019-11-17 01:16:46 +01:00
|
|
|
class Fader;
|
|
|
|
|
2019-11-25 22:45:01 +01:00
|
|
|
class WebServer
|
2019-11-17 01:16:46 +01:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
bool start(void);
|
|
|
|
|
|
|
|
void setFader(Fader *fader) { m_fader = fader;}
|
|
|
|
|
2019-11-25 22:45:01 +01:00
|
|
|
static WebServer &instance(void)
|
2019-11-17 01:16:46 +01:00
|
|
|
{
|
2019-11-25 22:45:01 +01:00
|
|
|
static WebServer theInstance;
|
2019-11-17 01:16:46 +01:00
|
|
|
return theInstance;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
httpsserver::HTTPServer *m_server;
|
2019-11-25 22:45:01 +01:00
|
|
|
ChallengeResponse m_cr;
|
2019-11-17 01:16:46 +01:00
|
|
|
|
|
|
|
Fader *m_fader;
|
|
|
|
|
2019-11-25 22:45:01 +01:00
|
|
|
WebServer(void);
|
2019-11-17 01:16:46 +01:00
|
|
|
|
|
|
|
static void serverTask(void *arg);
|
|
|
|
|
2019-11-20 22:42:35 +01:00
|
|
|
static void serveFile(String filename, httpsserver::HTTPResponse *res);
|
|
|
|
|
2019-11-17 01:16:46 +01:00
|
|
|
// handlers
|
|
|
|
static void handleRoot(httpsserver::HTTPRequest *req, httpsserver::HTTPResponse *res);
|
|
|
|
static void handleColor(httpsserver::HTTPRequest *req, httpsserver::HTTPResponse *res);
|
2019-11-25 22:45:01 +01:00
|
|
|
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);
|
2019-11-17 01:16:46 +01:00
|
|
|
static void handle404(httpsserver::HTTPRequest *req, httpsserver::HTTPResponse *res);
|
|
|
|
};
|