16#include <ove/net_httpd.h>
21#ifdef CONFIG_OVE_NET_HTTPD
68 return ove_httpd_req_method(raw_);
74 return ove_httpd_req_path(raw_);
80 return ove_httpd_req_query(raw_);
86 return ove_httpd_req_body(raw_);
92 return ove_httpd_req_body_len(raw_);
106 return ove_httpd_req_segment(raw_, idx);
113 ove_httpd_req_t *
raw()
const
119 ove_httpd_req_t *raw_;
157 return from_rc(ove_httpd_resp_json(raw_, status,
json));
170 return from_rc(ove_httpd_resp_html(raw_, status,
html, len));
185 return from_rc(ove_httpd_resp_send(raw_, status, content_type, body, len));
200 return from_rc(ove_httpd_resp_send_gz(raw_, status, content_type, body, len));
212 return from_rc(ove_httpd_resp_error(raw_, status, msg));
219 ove_httpd_resp_t *
raw()
const
225 ove_httpd_resp_t *raw_;
254 ove_httpd_config_t c{cfg.
port, cfg.max_body_size};
255 return from_rc(ove_httpd_start(&c));
277 return from_rc(ove_httpd_route(method, path, handler));
287 ove_httpd_register_builtin_routes();
298 ove_httpd_set_netif(netif);
301#ifdef CONFIG_OVE_AUDIO
305 ove_httpd_set_audio_graph(g);
309#ifdef CONFIG_OVE_INFER
313 ove_httpd_set_model(model);
319#ifdef CONFIG_OVE_NET_HTTPD_WS
354 return from_rc(ove_httpd_ws_send(raw_, data, len));
364 return from_rc(ove_httpd_ws_send(raw_, sv.data(), sv.size()));
368 ove_httpd_ws_conn_t *
raw()
const
374 ove_httpd_ws_conn_t *raw_;
394 return from_rc(ove_httpd_ws_route(path, on_message, on_close));
404inline int broadcast(
const char *path,
const void *data,
size_t len)
406 return ove_httpd_ws_broadcast(path, data, len);
415inline int broadcast(
const char *path, std::string_view sv)
417 return ove_httpd_ws_broadcast(path, sv.data(), sv.size());
423 return ove_httpd_ws_active_count();
Read-only view of an incoming HTTP request.
Definition net_httpd.hpp:50
size_t body_len() const
Returns the request body length in bytes.
Definition net_httpd.hpp:90
const char * query() const
Returns the query string after '?' (or NULL).
Definition net_httpd.hpp:78
Request(ove_httpd_req_t *raw)
Constructs a Request view from a raw C request pointer.
Definition net_httpd.hpp:56
const char * method() const
Returns the HTTP method string ("GET", "POST", etc.).
Definition net_httpd.hpp:66
ove_httpd_req_t * raw() const
Returns the raw oveRTOS request pointer.
Definition net_httpd.hpp:113
const char * segment(int idx) const
Returns a path segment by index.
Definition net_httpd.hpp:104
const char * body() const
Returns the request body (or NULL).
Definition net_httpd.hpp:84
const char * path() const
Returns the full request path (e.g. "/api/leds/0").
Definition net_httpd.hpp:72
Helper for building and sending an HTTP response.
Definition net_httpd.hpp:133
Result< void > html(int status, const char *html, size_t len) noexcept
Sends an HTML response.
Definition net_httpd.hpp:168
ove_httpd_resp_t * raw() const
Returns the raw oveRTOS response pointer.
Definition net_httpd.hpp:219
Result< void > send_gz(int status, const char *content_type, const void *body, size_t len) noexcept
Sends a pre-gzipped response (adds Content-Encoding: gzip).
Definition net_httpd.hpp:197
Result< void > send(int status, const char *content_type, const void *body, size_t len) noexcept
Sends a response with an arbitrary content type.
Definition net_httpd.hpp:182
Result< void > json(int status, const char *json) noexcept
Sends a JSON response.
Definition net_httpd.hpp:155
Response(ove_httpd_resp_t *raw)
Constructs a Response helper from a raw C response pointer.
Definition net_httpd.hpp:139
Result< void > error(int status, const char *msg) noexcept
Sends a JSON error response.
Definition net_httpd.hpp:210
Non-owning handle to an active WebSocket connection.
Definition net_httpd.hpp:338
Result< void > send(const void *data, size_t len) noexcept
Send a text message to this connection.
Definition net_httpd.hpp:352
Result< void > send(std::string_view sv) noexcept
Send a string_view as a text message.
Definition net_httpd.hpp:362
ove_httpd_ws_conn_t * raw() const
Returns the underlying ove_httpd_ws_conn_t * (for C-API escape hatches).
Definition net_httpd.hpp:368
Connection(ove_httpd_ws_conn_t *raw)
Wraps an opaque ove_httpd_ws_conn_t * from the handler callback.
Definition net_httpd.hpp:341
Strong ove::Error type, Result<T> alias, and std::error_code interop for the oveRTOS C++ binding.
void set_audio_graph(struct ove_audio_graph *g)
Set the audio graph for /api/audio/stats.
Definition net_httpd.hpp:303
void set_netif(ove_netif_t netif)
Associate a network interface with the dashboard routes.
Definition net_httpd.hpp:296
void register_builtin_routes()
Registers the built-in dashboard routes (/api/info, /api/leds, etc.).
Definition net_httpd.hpp:285
void set_model(ove_model_t model)
Set the ML model for /api/infer/stats.
Definition net_httpd.hpp:311
Result< void > route(const char *method, const char *path, Handler handler) noexcept
Registers a route handler.
Definition net_httpd.hpp:274
ove_httpd_handler_t Handler
Route handler callback type (same as the C typedef).
Definition net_httpd.hpp:229
Result< void > start(const Config &cfg={}) noexcept
Starts the HTTP server.
Definition net_httpd.hpp:252
void stop()
Stops the HTTP server and closes the listening socket.
Definition net_httpd.hpp:261
int active_count()
Return the number of active WebSocket connections.
Definition net_httpd.hpp:421
Result< void > route(const char *path, Handler on_message, CloseHandler on_close=nullptr) noexcept
Register a WebSocket route.
Definition net_httpd.hpp:391
ove_httpd_ws_handler_t Handler
WebSocket message handler type.
Definition net_httpd.hpp:378
ove_httpd_ws_close_handler_t CloseHandler
WebSocket close handler type.
Definition net_httpd.hpp:381
int broadcast(const char *path, const void *data, size_t len)
Broadcast a message to all WebSocket connections on a path.
Definition net_httpd.hpp:404
Top-level namespace for all oveRTOS C++ abstractions.
Definition app.hpp:20
Result< void > from_rc(int rc) noexcept
Lifts a substrate rc-code into a Result<void>.
Definition error.hpp:254
std::expected< T, Error > Result
std::expected-based result alias.
Definition error.hpp:139
HTTP server configuration.
Definition net_httpd.hpp:237
int max_body_size
Definition net_httpd.hpp:239
uint16_t port
Definition net_httpd.hpp:238
Common type definitions and concepts for the C++ wrapper layer.