From 3cc6303f929c313af61b8469760031beabad25bc Mon Sep 17 00:00:00 2001 From: Theis Pieter Hollebeek Date: Mon, 23 Mar 2026 15:26:47 +0100 Subject: [PATCH] backend: push http progress --- backend/src/http.cpp | 23 +++++++++++++++++++++++ backend/src/http.hpp | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 backend/src/http.cpp create mode 100644 backend/src/http.hpp diff --git a/backend/src/http.cpp b/backend/src/http.cpp new file mode 100644 index 0000000..fbec6a8 --- /dev/null +++ b/backend/src/http.cpp @@ -0,0 +1,23 @@ +#include "http.hpp" + +namespace mst { +auto HttpServer::start() -> Result +{ + while (1) { + auto res = this->listener.accept(); + if (res) { } + } +}; + +auto HttpServer::bind(const std::string& host, uint16_t port) + -> Result +{ + auto x = TcpListener::bind(host, port); + + if (!x) { + return std::unexpected(std::move(x.error())); + } + + return HttpServer(*x); +} +} diff --git a/backend/src/http.hpp b/backend/src/http.hpp new file mode 100644 index 0000000..87daf70 --- /dev/null +++ b/backend/src/http.hpp @@ -0,0 +1,36 @@ +#pragma once + +#include "tcp.hpp" +#include +#include +#include +#include + +namespace mst { +template using Result = std::expected; + +class HttpServer; + +class HttpDaemon { + +public: + HttpDaemon(HttpServer&, TcpConnection connection) + : connection(connection) { }; + +private: + TcpConnection connection; +}; + +class HttpServer { + +public: + auto start() -> Result; + static auto bind(const std::string& host, uint16_t port) + -> Result; + +private: + HttpServer(TcpListener listener) + : listener(listener) { }; + TcpListener listener; +}; +}