#pragma once

#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif

#include "Win32BaseIncludes.h"

#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0600
#endif
#include <http.h>

#include <string>

class AbstractWebApp;
class Win32WebRequest;
class HttpResponse;

class Win32WebServer
{
public:
	Win32WebServer(AbstractWebApp* webApp);

	~Win32WebServer();

	void clear();

	void initialize();

	void run();

private:
	bool onRequest(Win32WebRequest& request);
	bool onPostRequest(Win32WebRequest& request);

	bool sendHttpResponse(const Win32WebRequest& request, const HttpResponse& response);
	bool sendHttpPostResponse(const Win32WebRequest& request, const HttpResponse& response);

	AbstractWebApp* mWebApp{ nullptr };

	HANDLE mWorkingQueue{ 0 };
	std::string mListenUrl;
};