Files
led-hoop/c/lib/httpserver/httpserver.h
T
jimmyandClaude Opus 5.5 bf0429c505 Embed gzipped web assets at build time and type LED edit commands.
Generate the web UI headers from c/web/ via scripts/embed_file.py (minify + gzip) and serve them with Content-Encoding, replacing the checked-in web_*.h blobs. Move the LED driver/presets into lib/leds, and parse preset edits into a typed cmd_preset_t on core0 instead of passing raw JSON to core1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 22:18:10 +13:00

56 lines
1.9 KiB
C

#ifndef HTTPSERVER_H
#define HTTPSERVER_H
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct httpserver httpserver_t;
typedef struct httpserver_conn httpserver_conn_t;
typedef void (*httpserver_handler_t)(httpserver_conn_t *conn, const char *path, const char *query);
typedef void (*httpserver_ws_open_t)(httpserver_conn_t *ws);
typedef void (*httpserver_ws_msg_t)(httpserver_conn_t *ws, const uint8_t *data, size_t len, bool text);
typedef void (*httpserver_ws_close_t)(httpserver_conn_t *ws);
httpserver_t *httpserver_create(void);
void httpserver_route(httpserver_t *s, const char *method, const char *path, httpserver_handler_t fn);
void httpserver_websocket(httpserver_t *s, const char *path,
httpserver_ws_open_t on_open,
httpserver_ws_msg_t on_msg,
httpserver_ws_close_t on_close);
bool httpserver_listen(httpserver_t *s, uint16_t port);
void httpserver_send(httpserver_conn_t *conn, int status, const char *content_type,
const void *body, size_t body_len);
/* Stream a large const body (no copy of entire file into conn buffer).
* content_encoding may be NULL, or e.g. "gzip". */
void httpserver_send_static(httpserver_conn_t *conn, int status, const char *content_type,
const uint8_t *body, size_t body_len,
const char *content_encoding);
void httpserver_send_html(httpserver_conn_t *conn, const char *html);
/* POST/PUT body after headers (points into connection buffer). */
const char *httpserver_request_body(httpserver_conn_t *conn, size_t *len_out);
bool httpserver_ws_send(httpserver_conn_t *ws, const void *data, size_t len, bool text);
void httpserver_ws_broadcast(httpserver_t *s, const void *data, size_t len, bool text);
httpserver_t *httpserver_conn_server(httpserver_conn_t *conn);
#ifdef __cplusplus
}
#endif
#endif