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/include/theServer.h
2022-04-10 15:55:42 +02:00

39 lines
790 B
C

#ifndef THESERVER_H
#define THESERVER_H
#include "WebServer.h"
#include "cJSON.h"
static WebServer server(8080);
void 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);
server.send(response_code, "application/json", cJSON_Print(json_response));
cJSON_Delete(json_response);
}
static void getFirewallRules()
{
custom_message_response("firewall rules..", 200);
}
static void setup_routing()
{
server.on("/api/v1/firewall", HTTP_GET, getFirewallRules);
}
void setup_server()
{
setup_routing();
server.begin();
}
void handle_server_clients()
{
server.handleClient();
}
#endif