#pragma once
#include "../http/request.hpp"
#include "../http/response.hpp"
#include "../logger.hpp"
#include "../scheduler.hpp"
#include <cstdint>
#include <string>

namespace Middleware
{
	struct State
	{
		bool finished;
		bool awaiting;

		int const socketFd;
		int awaitingFd;

		Http::Request const & request;
		Http::Response & response;

		size_t middlewareIndex;

		State(int const socketFileDescriptor, Http::Request const & request, Http::Response & response);
	};

	class BaseMiddleware
	{
	protected:
		Logger & logger;

	public:
		virtual void HandleRequest(State & state, ScheduleHelper & scheduleHelper) = 0;

		BaseMiddleware(Logger & logger);
		virtual ~BaseMiddleware() = default;
	};
}