diff options
| author | Nikita Kostovsky <nikita@kostovsky.me> | 2025-11-14 21:05:12 +0100 |
|---|---|---|
| committer | Nikita Kostovsky <nikita@kostovsky.me> | 2025-11-14 21:05:12 +0100 |
| commit | 5df63c0bc7e3d6f1850d04f5bafbae2dd6fa619e (patch) | |
| tree | 7b98d59baec4aac62cab374e95795a2ce6b88d03 /src/protocols/httpserver.h | |
| parent | 36ef6a75e3418d88227e84ab175c0057e860c151 (diff) | |
organize things a bit, populate ICamera
Diffstat (limited to 'src/protocols/httpserver.h')
| -rw-r--r-- | src/protocols/httpserver.h | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/protocols/httpserver.h b/src/protocols/httpserver.h new file mode 100644 index 0000000..86b6ad6 --- /dev/null +++ b/src/protocols/httpserver.h @@ -0,0 +1,47 @@ +#pragma once + +// qt +#include <QHostAddress> +#include <QHttpServerResponse> +// #include <QObject> + +// orpheus +#include "iprotocol.h" + +class ICamera; +class QHttpServer; + +class HttpServer : public ProtocolBase +{ + // Q_OBJECT + +private: + struct Stats + { + uint64_t GET_pixels_us{0}; + } m_stats{0}; + +public: + static constexpr auto DefaultAddress = QHostAddress::Any; + static constexpr uint16_t DefaultPort{8080}; + +public: + explicit HttpServer(ICamera *camera, + // QObject *parent = nullptr, + const QHostAddress &address = DefaultAddress, + const uint16_t port = DefaultPort); + ~HttpServer() override = default; + + // TODO: methods starting with GET_/POST_ will be routed automatically +public: + QHttpServerResponse GET_pixels(); + + QHttpServerResponse POST_params(const QHttpServerRequest &request); + QHttpServerResponse GET_params(); + +private: + QHostAddress m_address{DefaultAddress}; + uint16_t m_port{DefaultPort}; + + std::shared_ptr<QHttpServer> m_server; +}; |
