forked from caozhiyi/CppNet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhttp_server.h
41 lines (28 loc) · 983 Bytes
/
http_server.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
31
32
33
34
35
36
37
38
39
40
41
#ifndef TEST_HTTP_HTTPSERVER_HEADER
#define TEST_HTTP_HTTPSERVER_HEADER
#include <unordered_map>
#include <functional>
#include <mutex>
#include "http_context.h"
#include "http_request.h"
#include "http_response.h"
#include "include/cppnet.h"
typedef std::function<void (const HttpRequest&, HttpResponse&)> HttpCallback;
class HttpServer {
public:
HttpServer();
~HttpServer();
void SetHttpCallback(const HttpCallback& cb) {
_http_call_back = cb;
}
void OnConnection(cppnet::Handle handle, uint32_t err);
void OnDisConnection(cppnet::Handle handle, uint32_t err);
void OnMessage(cppnet::Handle handle, cppnet::BufferPtr data,
uint32_t len);
void OnMessageSend(cppnet::Handle handle, uint32_t len);
private:
void OnRequest(cppnet::Handle handle, bool close, const HttpRequest&);
private:
HttpCallback _http_call_back;
};
#endif