backend: push http progress

This commit is contained in:
Theis Pieter Hollebeek 2026-03-23 15:26:47 +01:00
parent c7adfaf96a
commit 3cc6303f92
2 changed files with 59 additions and 0 deletions

23
backend/src/http.cpp Normal file
View File

@ -0,0 +1,23 @@
#include "http.hpp"
namespace mst {
auto HttpServer::start() -> Result<void>
{
while (1) {
auto res = this->listener.accept();
if (res) { }
}
};
auto HttpServer::bind(const std::string& host, uint16_t port)
-> Result<HttpServer>
{
auto x = TcpListener::bind(host, port);
if (!x) {
return std::unexpected(std::move(x.error()));
}
return HttpServer(*x);
}
}

36
backend/src/http.hpp Normal file
View File

@ -0,0 +1,36 @@
#pragma once
#include "tcp.hpp"
#include <cstdint>
#include <expected>
#include <netinet/in.h>
#include <string>
namespace mst {
template <typename T> using Result = std::expected<T, std::string>;
class HttpServer;
class HttpDaemon {
public:
HttpDaemon(HttpServer&, TcpConnection connection)
: connection(connection) { };
private:
TcpConnection connection;
};
class HttpServer {
public:
auto start() -> Result<void>;
static auto bind(const std::string& host, uint16_t port)
-> Result<HttpServer>;
private:
HttpServer(TcpListener listener)
: listener(listener) { };
TcpListener listener;
};
}