add http_api

This commit is contained in:
Stephan Mühl
2023-03-31 14:29:48 +02:00
parent 249074d022
commit 1b4a5b2952
16 changed files with 1217 additions and 570 deletions

View File

@@ -29,6 +29,11 @@ void FSWebServer::addHandler(const Uri &uri, WebServerClass::THandlerFunction ha
webserver->on(uri, HTTP_ANY, handler);
}
void FSWebServer::onNotFound(WebServerClass::THandlerFunction handler)
{
webserver->onNotFound(handler);
}
// List all files saved in the selected filesystem
bool FSWebServer::checkDir(char *dirname, uint8_t levels)
{
@@ -80,7 +85,7 @@ bool FSWebServer::begin(const char *path)
webserver->on("/edit", HTTP_PUT, std::bind(&FSWebServer::handleFileCreate, this));
webserver->on("/edit", HTTP_DELETE, std::bind(&FSWebServer::handleFileDelete, this));
#endif
webserver->onNotFound(std::bind(&FSWebServer::handleRequest, this));
//webserver->onNotFound(std::bind(&FSWebServer::handleRequest, this));
webserver->on("/favicon.ico", HTTP_GET, std::bind(&FSWebServer::replyOK, this));
webserver->on("/", HTTP_GET, std::bind(&FSWebServer::handleIndex, this));
#ifdef INCLUDE_SETUP_HTM
@@ -153,7 +158,6 @@ IPAddress FSWebServer::startWiFi(uint32_t timeout, const char *apSSID, const cha
#elif defined(ESP32)
wifi_config_t conf;
esp_wifi_get_config(WIFI_IF_STA, &conf);
_ssid = reinterpret_cast<const char *>(conf.sta.ssid);
_pass = reinterpret_cast<const char *>(conf.sta.password);
#endif

View File

@@ -86,6 +86,7 @@ public:
void addHandler(const Uri &uri, HTTPMethod method, WebServerClass::THandlerFunction fn);
void addHandler(const Uri &uri, WebServerClass::THandlerFunction handler);
void onNotFound(WebServerClass::THandlerFunction handler);
void setCaptiveWebage(const char *url);