VWeb/Source/MiddleWare.cpp

33 lines
1 KiB
C++

#include <VWeb.h>
namespace VWeb {
void MiddleWareHandler::HandlePre(Ref<Request> &request) {
for (auto &[key, middleWare] : m_MiddleWares) {
middleWare->PreHandle(*request);
}
}
void MiddleWareHandler::HandlePost(Ref<Request> &request,
Ref<Response> &response) {
for (auto &[key, middleWare] : m_MiddleWares) {
middleWare->PostHandle(*request, *response);
}
}
void MiddleWareHandler::Shutdown(Ref<Request> &request,
Ref<Response> &response) {
for (auto &[key, middleWare] : m_MiddleWares) {
middleWare->Shutdown(*request, *response);
}
}
Ref<MiddleWare> MiddleWareHandler::GetById(const char *id) {
return m_MiddleWares[id];
}
Ref<MiddleWare> MiddleWareHandler::SetById(const char *id,
const Ref<MiddleWare> &middleWare) {
m_MiddleWares[id] = middleWare;
return middleWare;
}
void MiddleWareHandler::RemoveById(const char *id) {
if (m_MiddleWares.contains(id))
m_MiddleWares.erase(id);
}
} // namespace VWeb