10#define OVE_NET_HTTPD_H
26#include "ove_config.h"
34#ifdef CONFIG_OVE_NET_HTTPD
37#define OVE_HTTPD_MAX_ROUTES 16
40#define OVE_HTTPD_MAX_SEGMENTS 8
43typedef struct ove_httpd_req ove_httpd_req_t;
46typedef struct ove_httpd_resp ove_httpd_resp_t;
52typedef int (*ove_httpd_handler_t)(ove_httpd_req_t *req,
53 ove_httpd_resp_t *resp);
72int ove_httpd_start(
const ove_httpd_config_t *cfg);
77void ove_httpd_stop(
void);
87int ove_httpd_route(
const char *method,
const char *path,
88 ove_httpd_handler_t handler);
95void ove_httpd_register_builtin_routes(
void);
109#ifdef CONFIG_OVE_AUDIO
115#ifdef CONFIG_OVE_INFER
123const char *ove_httpd_req_method(ove_httpd_req_t *req);
126const char *ove_httpd_req_path(ove_httpd_req_t *req);
129const char *ove_httpd_req_query(ove_httpd_req_t *req);
132const char *ove_httpd_req_body(ove_httpd_req_t *req);
135size_t ove_httpd_req_body_len(ove_httpd_req_t *req);
146const char *ove_httpd_req_segment(ove_httpd_req_t *req,
int idx);
151int ove_httpd_resp_json(ove_httpd_resp_t *resp,
int status,
155int ove_httpd_resp_html(ove_httpd_resp_t *resp,
int status,
156 const char *html,
size_t len);
159int ove_httpd_resp_send(ove_httpd_resp_t *resp,
int status,
160 const char *content_type,
161 const void *body,
size_t len);
164int ove_httpd_resp_send_gz(ove_httpd_resp_t *resp,
int status,
165 const char *content_type,
166 const void *body,
size_t len);
169int ove_httpd_resp_error(ove_httpd_resp_t *resp,
int status,
170 const char *message);
174#ifdef CONFIG_OVE_NET_HTTPD_WS
177typedef struct ove_httpd_ws_conn ove_httpd_ws_conn_t;
185typedef void (*ove_httpd_ws_handler_t)(ove_httpd_ws_conn_t *conn,
186 const void *data,
size_t len);
192typedef void (*ove_httpd_ws_close_handler_t)(ove_httpd_ws_conn_t *conn);
206int ove_httpd_ws_route(
const char *path,
207 ove_httpd_ws_handler_t on_message,
208 ove_httpd_ws_close_handler_t on_close);
218int ove_httpd_ws_send(ove_httpd_ws_conn_t *conn,
219 const void *data,
size_t len);
229int ove_httpd_ws_broadcast(
const char *path,
230 const void *data,
size_t len);
233int ove_httpd_ws_active_count(
void);
236int ove_httpd_ws_is_upgrade(
const char *headers);
237int ove_httpd_ws_handshake(
const char *headers,
size_t headers_len,
240 ove_socket_storage_t *storage);
241void ove_httpd_ws_poll(
void);
252void ove_httpd_log_append(
const char *line);
258static inline void ove_httpd_stop(
void) {}
259static inline void ove_httpd_register_builtin_routes(
void) {}
260static inline void ove_httpd_log_append(
const char *line) { (void)line; }
#define OVE_ERR_NOT_SUPPORTED
The requested feature is not supported by the active backend.
Definition types.h:38
struct ove_netif * ove_netif_t
Opaque handle for a network interface.
Definition types.h:124
struct ove_socket * ove_socket_t
Opaque handle for a network socket.
Definition types.h:121
struct ove_model * ove_model_t
Opaque handle for an ML inference model session.
Definition types.h:118
Audio processing graph instance.
Definition audio.h:93