real simple https on esp8266

This commit is contained in:
Florian Hoss 2022-04-24 01:09:17 +02:00
parent a4870fd6fd
commit 6692bb1385
2 changed files with 66 additions and 5 deletions

View file

@ -9,7 +9,8 @@ namespace fw
#ifdef ESP32
this->server = new WebServer(port);
#elif defined(ESP8266)
this->server = new ESP8266WebServer(port);
this->server = new ESP8266WebServerSecure(port);
this->serverCache = new ServerSessions(5);
#endif
this->setup_routing();
Serial.println("Starting server...");
@ -56,6 +57,10 @@ namespace fw
void API::setup_routing()
{
#ifdef ESP8266
this->server->getServer().setRSACert(new BearSSL::X509List(serverCert), new BearSSL::PrivateKey(serverKey));
this->server->getServer().setCache(serverCache);
#endif
this->server->on(UriRegex("/api/v1/firewall/([0-9]+)"), HTTP_GET, std::bind(&API::get_firewall_rule_handler, this));
this->server->on("/api/v1/firewall", HTTP_GET, std::bind(&API::get_firewall_rules_handler, this));
this->server->on("/api/v1/firewall", HTTP_POST, std::bind(&API::post_firewall_handler, this));