This repository has been archived on 2024-10-30. You can view files and clone it, but cannot push or open issues or pull requests.
esp-firewall/SourceCode/arduino/lib/Firewall/esp32API.hpp
2022-04-20 21:17:34 +02:00

44 lines
1.2 KiB
C++

#ifndef ESP32_API_HPP
#define ESP32_API_HPP
#include "HTTPSServer.hpp"
#include "SSLCert.hpp"
#include "HTTPRequest.hpp"
#include "HTTPResponse.hpp"
#include "ArduinoJson.h"
#include "FirewallTypes.h"
#include "esp32Firewall.hpp"
using namespace httpsserver;
namespace firewall
{
class API : public Firewall
{
private:
HTTPSServer *server;
SSLCert *certificate;
void setup_certificate();
void setup_routing();
void get_firewall_rule_handler(HTTPRequest *, HTTPResponse *);
void get_firewall_rules_handler(HTTPRequest *, HTTPResponse *);
bool request_has_firewall_parameter(ResourceParameters *);
void post_firewall_handler(HTTPRequest *, HTTPResponse *);
void delete_firewall_handler(HTTPRequest *, HTTPResponse *);
void not_found_handler(HTTPRequest *, HTTPResponse *);
void json_generic_response(HTTPResponse *, String, const uint16_t);
void json_message_response(HTTPResponse *, String, const uint16_t);
String construct_json_firewall_rule(firewall_rule_t *);
String construct_json_firewall();
public:
API(const uint16_t = 8080);
~API();
void handle_clients();
};
}
#endif