#pragma once

#include "PlatformSocketServer.h"

#include <memory>

class AbstractWebApp;
class Socket;

class HttpServer
{
public:
	struct Address
	{
		std::string mPrefix;
		std::string mHost;
		unsigned int mPort{ 8000 };
	};

	HttpServer();
	~HttpServer();

	void run(AbstractWebApp* webApp, Address mListenAddress);

private:
	void onConnection(Socket* socket);

	void onFailure(const std::string& reason);

	AbstractWebApp* mWebApp{ nullptr };
	std::unique_ptr<PlatformSocketServer> mSocketServer;
};