VWeb/Includes/PreMiddleWare.h
Maurice Grönwoldt 5bb68a7d02 Split VWeb into smaller headers
We have no make install support... so we don't need to have everything as a single-header and lib file.
2023-09-16 16:29:03 +02:00

48 lines
1 KiB
C++

#pragma once
#include "MiddleWare.h"
#include <functional>
#include <thread>
namespace VWeb {
typedef std::function<PreMiddleWareReturn(Request &req)> 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<std::thread> m_GCThread;
std::mutex m_Mutex;
std::unordered_map<std::string, Ref<Session>> 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