-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHttpServer.h
30 lines (25 loc) · 911 Bytes
/
HttpServer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
//
// Created by 12096 on 2022/12/7.
//
#ifndef MYMUDUO_HTTPSERVER_H
#define MYMUDUO_HTTPSERVER_H
#include "TcpServer.h"
#include "HttpRequest.h"
#include "HttpResponse.h"
#include "Logger.h"
#include "HttpContext.h"
class HttpServer{
using HttpCallback = std::function<void(const HttpRequest&, HttpResponse*)>;
public:
HttpServer(EventLoop* loop, const InetAddress& listenAddr, const std::string& name, TcpServer::Option option);
void setHttpCallback(const HttpCallback &httpCallback);
void setThreadNum(int threadNum);
void start();
private:
HttpCallback httpCallback_;
TcpServer tcpServer_;
void onConnection(const TcpConnectionPtr& conn);
void onMessage(const TcpConnectionPtr& conn, Buffer* buf, TimeStamp receiveTime);
void onRequest(const TcpConnectionPtr& conn, const HttpRequest& httpRequest);
};
#endif //MYMUDUO_HTTPSERVER_H