oveRTOS C API
Embedded RTOS framework — build system, configuration, and portable C API
Loading...
Searching...
No Matches
Data Structures | Macros | Typedefs | Functions
net_httpd.h File Reference
#include "ove/types.h"
#include "ove/net.h"
#include "ove_config.h"
#include <stddef.h>
Include dependency graph for net_httpd.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ove_httpd_config_t
 HTTP server configuration. More...
 

Macros

#define OVE_HTTPD_MAX_ROUTES   16
 Maximum number of registered routes.
 
#define OVE_HTTPD_MAX_SEGMENTS   8
 Maximum path segments for parsing (e.g. /api/leds/0 = 3).
 

Typedefs

typedef struct ove_httpd_req ove_httpd_req_t
 Opaque HTTP request.
 
typedef struct ove_httpd_resp ove_httpd_resp_t
 Opaque HTTP response.
 
typedef int(* ove_httpd_handler_t) (ove_httpd_req_t *req, ove_httpd_resp_t *resp)
 Route handler callback.
 
typedef struct ove_httpd_ws_conn ove_httpd_ws_conn_t
 Opaque WebSocket connection handle.
 
typedef void(* ove_httpd_ws_handler_t) (ove_httpd_ws_conn_t *conn, const void *data, size_t len)
 WebSocket message callback.
 
typedef void(* ove_httpd_ws_close_handler_t) (ove_httpd_ws_conn_t *conn)
 WebSocket close callback.
 

Functions

int ove_httpd_start (const ove_httpd_config_t *cfg)
 Start the HTTP server.
 
void ove_httpd_stop (void)
 Stop the HTTP server and close the listening socket.
 
int ove_httpd_route (const char *method, const char *path, ove_httpd_handler_t handler)
 Register a route handler.
 
void ove_httpd_register_builtin_routes (void)
 Register built-in dashboard routes (/api/info, /api/leds, etc.).
 
void ove_httpd_set_netif (ove_netif_t netif)
 Set the network interface used by built-in dashboard routes.
 
void ove_httpd_set_audio_graph (struct ove_audio_graph *g)
 Set the audio graph for /api/audio/stats.
 
void ove_httpd_set_model (ove_model_t model)
 Set the ML model for /api/infer/stats.
 
const char * ove_httpd_req_method (ove_httpd_req_t *req)
 Get the HTTP method string ("GET" or "POST").
 
const char * ove_httpd_req_path (ove_httpd_req_t *req)
 Get the full request path (e.g. "/api/leds/0").
 
const char * ove_httpd_req_query (ove_httpd_req_t *req)
 Get the query string after '?' (or NULL).
 
const char * ove_httpd_req_body (ove_httpd_req_t *req)
 Get the request body (or NULL).
 
size_t ove_httpd_req_body_len (ove_httpd_req_t *req)
 Get the request body length.
 
const char * ove_httpd_req_segment (ove_httpd_req_t *req, int idx)
 Get a path segment by index.
 
int ove_httpd_resp_json (ove_httpd_resp_t *resp, int status, const char *json)
 Send a JSON response.
 
int ove_httpd_resp_html (ove_httpd_resp_t *resp, int status, const char *html, size_t len)
 Send an HTML response.
 
int ove_httpd_resp_send (ove_httpd_resp_t *resp, int status, const char *content_type, const void *body, size_t len)
 Send a response with arbitrary content type.
 
int ove_httpd_resp_send_gz (ove_httpd_resp_t *resp, int status, const char *content_type, const void *body, size_t len)
 Send a pre-gzipped response (adds Content-Encoding: gzip).
 
int ove_httpd_resp_error (ove_httpd_resp_t *resp, int status, const char *message)
 Send a JSON error response.
 
int ove_httpd_ws_route (const char *path, ove_httpd_ws_handler_t on_message, ove_httpd_ws_close_handler_t on_close)
 Register a WebSocket route.
 
int ove_httpd_ws_send (ove_httpd_ws_conn_t *conn, const void *data, size_t len)
 Send a text message to a WebSocket connection.
 
int ove_httpd_ws_broadcast (const char *path, const void *data, size_t len)
 Broadcast a text message to all WebSocket connections on a path.
 
int ove_httpd_ws_active_count (void)
 Return the number of active WebSocket connections.
 
int ove_httpd_ws_is_upgrade (const char *headers)
 Return non-zero if the HTTP headers request a WebSocket upgrade.
 
int ove_httpd_ws_handshake (const char *headers, size_t headers_len, const char *path, ove_socket_t sock, ove_socket_storage_t *storage)
 Complete the WebSocket upgrade handshake on sock.
 
void ove_httpd_ws_poll (void)
 Drive the WS subsystem from the httpd task's poll loop.
 
void ove_httpd_log_append (const char *line)
 Feed a log line into the httpd log ring buffer.