42 lines
860 B
C++
42 lines
860 B
C++
// Wrapper for ESP8266WebServer with Filesystem as HTTP source
|
|
|
|
#pragma once
|
|
|
|
#include <ESP8266WebServer.h>
|
|
#include <stdarg.h>
|
|
#include "filesys.h"
|
|
|
|
// debug log <ESP8266WebServer.h>
|
|
// #define DEBUGV(f,...) do { Serial.printf(PSTR(f), ##__VA_ARGS__); } while (0)
|
|
|
|
#define LOG_STR "[HTTPServer]"
|
|
|
|
|
|
class HTTPServer : public ESP8266WebServer {
|
|
|
|
private:
|
|
const char* rootDir = "/";
|
|
|
|
void listRoot() {
|
|
ls(rootDir);
|
|
}
|
|
void logf(const char *format, ...) {
|
|
va_list args;
|
|
va_start(args, format);
|
|
Serial.print(LOG_STR);
|
|
Serial.printf(format, args);
|
|
va_end(args);
|
|
}
|
|
|
|
public:
|
|
HTTPServer(const int _port, const char* _rootDir) :
|
|
ESP8266WebServer(_port), rootDir(_rootDir)
|
|
{ }
|
|
~HTTPServer()
|
|
{
|
|
Serial.printf("[HTTPServer] shut down ...\n\r");
|
|
}
|
|
|
|
bool start();
|
|
};
|