#include "Includes/VWeb.h" namespace VWeb { std::optional> MiddleWareHandler::HandlePre(Ref &request) { for (auto &[key, middleWare] : m_MiddleWares) { auto data = middleWare->PreHandle(*request); if (data.has_value()) return data; } return {}; } void MiddleWareHandler::HandlePost(Ref &request, Ref &response) { for (auto &[key, middleWare] : m_MiddleWares) { if (!middleWare->PostHandle(*request, *response)) { break; } } } void MiddleWareHandler::Shutdown(Ref &request, Ref &response) { for (auto &[key, middleWare] : m_MiddleWares) { middleWare->Shutdown(*request, *response); } } Ref MiddleWareHandler::GetById(const char *id) { return m_MiddleWares[id]; } Ref MiddleWareHandler::SetById(const char *id, const Ref &middleWare) { m_MiddleWares[id] = middleWare; return middleWare; } void MiddleWareHandler::RemoveById(const char *id) { if (m_MiddleWares.contains(id)) m_MiddleWares.erase(id); } } // namespace VWeb