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/Firewall.cpp
2022-04-10 20:46:54 +02:00

27 lines
No EOL
757 B
C++

#include "Firewall.h"
ESPFirewall::ESPFirewall()
{
log_i("Firewall!");
firewall_api->on("/api/v1/firewall", HTTP_GET, std::bind(&ESPFirewall::get_firewall_rules, this));
firewall_api->begin();
}
void ESPFirewall::get_firewall_rules()
{
this->custom_message_response("Firewall", 200);
}
void ESPFirewall::custom_message_response(const char *message, int response_code)
{
cJSON *json_response = cJSON_CreateObject();
cJSON_AddBoolToObject(json_response, "ok", true);
cJSON_AddStringToObject(json_response, "message", message);
firewall_api->send(response_code, "application/json", cJSON_Print(json_response));
cJSON_Delete(json_response);
}
void ESPFirewall::handle_clients()
{
this->firewall_api->handleClient();
}