Full C++23 framework tree: runtime, observability, security, data, app, realtime, supervisor, clients, CLI, example plus enterprise tenancy, audit, operability, governance, supplychain. Postgres via docker compose for tests.
45 lines
1.0 KiB
C++
45 lines
1.0 KiB
C++
#pragma once
|
|
|
|
// Minimal loopback HTTP/1.1 server for manual verification and the real-HTTP
|
|
// round-trip test. Sequential accept loop, static caps, no TLS, no HTTP/2.
|
|
// Gap: real event loop, timeouts, keep-alive, H2, and compression live in
|
|
// 01-runtime.md; this server exists only to prove the stack end to end.
|
|
|
|
#include <atomic>
|
|
#include <memory>
|
|
#include <string>
|
|
#include <thread>
|
|
|
|
#include "App.hpp"
|
|
|
|
namespace molo::example::fw {
|
|
|
|
class Server {
|
|
public:
|
|
explicit Server(std::shared_ptr<Application> app);
|
|
~Server();
|
|
|
|
Server(const Server&) = delete;
|
|
Server& operator=(const Server&) = delete;
|
|
|
|
bool start(const std::string& host, int port);
|
|
void stop();
|
|
int port() const;
|
|
bool running() const;
|
|
|
|
private:
|
|
void loop();
|
|
void handle_one(int fd);
|
|
|
|
std::shared_ptr<Application> app_;
|
|
int listen_fd_ = -1;
|
|
int port_ = 0;
|
|
std::atomic<bool> running_{false};
|
|
std::thread worker_;
|
|
};
|
|
|
|
std::string http_roundtrip(const std::string& host, int port,
|
|
const std::string& raw_request);
|
|
|
|
} // namespace molo::example::fw
|