/* * SPDX-License-Identifier: Apache-2.0 */ #pragma once #include "esp_err.h" #include "esp_http_server.h" #ifdef __cplusplus extern "C" { #endif #define WEB_API_MSG_MAX 2048 // a request message: {"method","path","body","host"} #define WEB_API_REPLY_MAX 8192 // a reply envelope: {"status","body"} /** @brief Start the HTTP server on port 80 (UI and JSON API). */ esp_err_t web_start(void); /** * @brief Add Access-Control-Allow-Origin for a LAN or localhost page that asked (the Origin header). * Call before the response is sent. Other origins get no header, so the browser blocks them. */ void web_allow_lan_origin(httpd_req_t *req); /** * @brief Run one API request without HTTP, as the WebSocket does: msg is * {"method": "GET" or "POST", "path": "/api/...", "body": ..., "host": optional relay target}. * out gets the envelope {"status": n, "body": ""}. Used by the USB config port. */ void web_api_call(const char *msg, char *out, size_t cap); #ifdef __cplusplus } #endif