#pragma once #include "MiddleWare.h" #include #include namespace VWeb { typedef std::function AuthFunction; class AuthWare : public MiddleWare { public: AuthWare() = default; ~AuthWare() = default; PreMiddleWareReturn PreHandle(Request &request) override; void SetAuthMethod(AuthFunction function) { m_AuthFunction = std::move(function); } protected: AuthFunction m_AuthFunction{nullptr}; }; class SessionManager : public MiddleWare { public: SessionManager(); ~SessionManager(); PreMiddleWareReturn PreHandle(Request &request) override; bool PostHandle(Request &request, Response &response) override; protected: void GC(); protected: Ref m_GCThread; std::mutex m_Mutex; std::unordered_map> m_Sessions; int m_Counter{-1}; bool m_IsRunning{true}; }; class CookieManager : public MiddleWare { public: CookieManager() = default; ~CookieManager() = default; PreMiddleWareReturn PreHandle(Request &) override; }; } // namespace VWeb