45 lines
1023 B
C++
45 lines
1023 B
C++
#ifndef __HTTPServer_h__
|
|
#define __HTTPServer_h__
|
|
|
|
#include "TCPServer.h"
|
|
#include "HTTPSessions.h"
|
|
#include "HTTPPageList.h"
|
|
#include "HTTPActionList.h"
|
|
#include "HTTPConnection.h"
|
|
#include "HTTPGETHandler.h"
|
|
#include "HTTPPOSTHandler.h"
|
|
#include "HTTPPUTHandler.h"
|
|
|
|
namespace http {
|
|
|
|
class TCPSession;
|
|
|
|
class HTTPServer : public core::TCPServer {
|
|
|
|
public:
|
|
HTTPServer(core::EPoll &ePoll, core::IPAddress ipAddress, HTTPSessions &httpSessions)
|
|
: TCPServer(ePoll, ipAddress), httpSessions(httpSessions) {
|
|
commands.add(getHandler, "GET");
|
|
commands.add(postHandler, "POST");
|
|
commands.add(putHandler, "PUT");
|
|
}
|
|
|
|
core::TCPSession * getSocketAccept(core::EPoll &epoll) override {
|
|
return new HTTPConnection(ePoll, *this);
|
|
}
|
|
|
|
HTTPSessions &httpSessions;
|
|
HTTPPageList pageList;
|
|
HTTPActionList actionList;
|
|
|
|
private:
|
|
HTTPGETHandler getHandler;
|
|
HTTPPOSTHandler postHandler;
|
|
HTTPPUTHandler putHandler;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
#endif
|