16#include <ove/net_httpd.h>
20#ifdef CONFIG_OVE_NET_HTTPD
52 explicit Request(ove_httpd_req_t *raw) : raw_(raw) {}
54 Request(
const Request &) =
delete;
55 Request &operator=(
const Request &) =
delete;
56 Request(Request &&) =
delete;
57 Request &operator=(Request &&) =
delete;
60 const char *method()
const {
return ove_httpd_req_method(raw_); }
63 const char *path()
const {
return ove_httpd_req_path(raw_); }
66 const char *query()
const {
return ove_httpd_req_query(raw_); }
69 const char *body()
const {
return ove_httpd_req_body(raw_); }
72 size_t body_len()
const {
return ove_httpd_req_body_len(raw_); }
83 const char *segment(
int idx)
const {
84 return ove_httpd_req_segment(raw_, idx);
91 ove_httpd_req_t *raw()
const {
return raw_; }
94 ove_httpd_req_t *raw_;
113 explicit Response(ove_httpd_resp_t *raw) : raw_(raw) {}
115 Response(
const Response &) =
delete;
116 Response &operator=(
const Response &) =
delete;
117 Response(Response &&) =
delete;
118 Response &operator=(Response &&) =
delete;
126 int json(
int status,
const char *json) {
127 return ove_httpd_resp_json(raw_, status, json);
137 int html(
int status,
const char *html,
size_t len) {
138 return ove_httpd_resp_html(raw_, status, html, len);
149 int send(
int status,
const char *content_type,
150 const void *body,
size_t len) {
151 return ove_httpd_resp_send(raw_, status, content_type,
163 int send_gz(
int status,
const char *content_type,
164 const void *body,
size_t len) {
165 return ove_httpd_resp_send_gz(raw_, status, content_type,
175 int error(
int status,
const char *msg) {
176 return ove_httpd_resp_error(raw_, status, msg);
183 ove_httpd_resp_t *raw()
const {
return raw_; }
186 ove_httpd_resp_t *raw_;
190using Handler = ove_httpd_handler_t;
200 int max_body_size{1024};
212[[nodiscard]]
inline int start(
const Config &cfg = {}) {
213 ove_httpd_config_t c{cfg.port, cfg.max_body_size};
214 return ove_httpd_start(&c);
231[[nodiscard]]
inline int route(
const char *method,
const char *path,
233 return ove_httpd_route(method, path, handler);
241inline void register_builtin_routes() {
242 ove_httpd_register_builtin_routes();
251inline void set_netif(ove_netif_t netif) {
252 ove_httpd_set_netif(netif);
255#ifdef CONFIG_OVE_AUDIO
257inline void set_audio_graph(
struct ove_audio_graph *g) {
258 ove_httpd_set_audio_graph(g);
262#ifdef CONFIG_OVE_INFER
264inline void set_model(ove_model_t model) {
265 ove_httpd_set_model(model);
271#ifdef CONFIG_OVE_NET_HTTPD_WS
290 explicit Connection(ove_httpd_ws_conn_t *raw) : raw_(raw) {}
298 int send(
const void *data,
size_t len) {
299 return ove_httpd_ws_send(raw_, data, len);
307 int send(std::string_view sv) {
308 return ove_httpd_ws_send(raw_, sv.data(), sv.size());
311 ove_httpd_ws_conn_t *raw()
const {
return raw_; }
314 ove_httpd_ws_conn_t *raw_;
318using Handler = ove_httpd_ws_handler_t;
321using CloseHandler = ove_httpd_ws_close_handler_t;
330[[nodiscard]]
inline int route(
const char *path,
332 CloseHandler on_close =
nullptr) {
333 return ove_httpd_ws_route(path, on_message, on_close);
343inline int broadcast(
const char *path,
const void *data,
size_t len) {
344 return ove_httpd_ws_broadcast(path, data, len);
353inline int broadcast(
const char *path, std::string_view sv) {
354 return ove_httpd_ws_broadcast(path, sv.data(), sv.size());
358inline int active_count() {
359 return ove_httpd_ws_active_count();
Top-level namespace for all oveRTOS C++ abstractions.
Definition app.hpp:19
Common type definitions and concepts for the C++ wrapper layer.