rewrite in progress...

This commit is contained in:
Florian Hoss 2022-04-23 23:36:44 +02:00
parent e77ced2f0a
commit 17a1a5176f
6 changed files with 221 additions and 13 deletions

View file

@ -0,0 +1,49 @@
#ifndef ESP32_API_HPP
#define ESP32_API_HPP
#ifdef ESP32
#include <WebServer.h>
#elif defined(ESP8266)
#include <ESP8266WebServer.h>
#endif
#include <uri/UriRegex.h>
#include "esp32Firewall.hpp"
#include "Utils.hpp"
namespace firewall
{
class API : public Firewall
{
private:
#ifdef ESP32
WebServer *server;
#elif defined(ESP8266)
ESP8266WebServer *server;
#endif
credential_t credentials;
ok_t setup_auth(const char *, const char *);
void setup_routing();
void get_firewall_rule_handler();
void get_firewall_rules_handler();
void post_firewall_handler();
void delete_firewall_handler();
void not_found_handler();
String json_new_attribute(String key, String value, bool last = false);
String json_new_attribute(String key, uint8_t value, bool last = false);
void json_generic_response(String serialized_string, const uint16_t response_code);
void json_message_response(String message, const uint16_t response_code);
String construct_json_firewall_rule(firewall_rule_t *);
String construct_json_firewall();
public:
API(const char *, const char *, const uint16_t = 8080);
~API();
void handle_client();
};
}
#endif