|
oveRTOS C++ API
C++20 RAII wrappers for the oveRTOS C API
|
Helper for building and sending an HTTP response. More...
#include <net_httpd.hpp>
Public Member Functions | |
| Response (ove_httpd_resp_t *raw) | |
| Constructs a Response helper from a raw C response pointer. | |
| Response (const Response &)=delete | |
| Response & | operator= (const Response &)=delete |
| Response (Response &&)=delete | |
| Response & | operator= (Response &&)=delete |
| Result< void > | json (int status, const char *json) noexcept |
| Sends a JSON response. | |
| Result< void > | html (int status, const char *html, size_t len) noexcept |
| Sends an HTML response. | |
| Result< void > | send (int status, const char *content_type, const void *body, size_t len) noexcept |
| Sends a response with an arbitrary content type. | |
| 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). | |
| Result< void > | error (int status, const char *msg) noexcept |
| Sends a JSON error response. | |
| ove_httpd_resp_t * | raw () const |
| Returns the raw oveRTOS response pointer. | |
Helper for building and sending an HTTP response.
Wraps the opaque ove_httpd_resp_t pointer that is passed into route handler callbacks. Does not own the underlying storage; the pointer remains valid for the duration of the handler invocation.
|
inlineexplicit |
Constructs a Response helper from a raw C response pointer.
| [in] | raw | Opaque response handle from the server callback. |
|
inlinenoexcept |
Sends a JSON response.
| [in] | status | HTTP status code (e.g. 200). |
| [in] | json | NUL-terminated JSON string. |
Result<void> on success; unexpected Error on failure.
|
inlinenoexcept |
Sends an HTML response.
| [in] | status | HTTP status code. |
| [in] | html | HTML data. |
| [in] | len | HTML data length in bytes. |
Result<void> on success; unexpected Error on failure.
|
inlinenoexcept |
|
inlinenoexcept |
Sends a pre-gzipped response (adds Content-Encoding: gzip).
| [in] | status | HTTP status code. |
| [in] | content_type | Content-Type header value. |
| [in] | body | Gzip-compressed response body. |
| [in] | len | Compressed body length in bytes. |
Result<void> on success; unexpected Error on failure.
|
inlinenoexcept |
Sends a JSON error response.
| [in] | status | HTTP status code (e.g. 404, 500). |
| [in] | msg | Error message string. |
Result<void> on success; unexpected Error on failure.
|
inline |
Returns the raw oveRTOS response pointer.
ove_httpd_resp_t pointer.