Service_NSSM/SDK/CCServlet/include/CCWebServlet.h
“leonzor” c16ad2537c d
2025-03-06 13:47:33 +08:00

52 lines
1.1 KiB
C++

#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<void(CCRequest& ,CCResponse&)>;
std::map<std::string,RequestFunc> RequestFun;
CCString ServerIP;
CCSocket m_Socket;
int numThreads = 5,ListenMax = 50,RootLen = 0;
bool FlagRun = true;
CCThread m_Thread;
CCThreadPool m_ThreadPool;
std::vector<std::string> 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