#ifndef CCWeb_Servlet_H #define CCWeb_Servlet_H #pragma once #include "CCSocket.h" #include "../../include/CCJSONObject.h" #include "../../include/CCThread.h" #include "../../include/CCThreadPool.h" #include "CCString.h" #include "CCResponse.h" #define Buffer_Max 1024 class CCWebServlet:public CCResponse { private: using RequestFunc = std::function; std::map RequestFun; CCString ServerIP; CCSocket m_Socket; int numThreads = 5,ListenMax = 50,RootLen = 0; bool FlagRun = true; CCThread m_Thread; CCThreadPool m_ThreadPool; std::vector PathSix; CORS CORSConfig; std::mutex m_Mutex; public: public: CCWebServlet() = default; void SetThreadNumber(int headcount); void SetWebServlet(CCString RootPath,RequestFunc RFunc); void SetAddRootPath(const CCString& rootPath); bool Sign() const; bool Start(CCString IP,int port); void Close(); void SetCorsConfig(CORS& cors); private: void ProcessRequest(); void ResponseData(CCSocket & socket); }; #endif