-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathxhttp_server.h
More file actions
50 lines (49 loc) · 1.79 KB
/
xhttp_server.h
File metadata and controls
50 lines (49 loc) · 1.79 KB
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
42
43
44
45
46
47
48
49
50
// Copyright (c) 2017-2018 Telos Foundation & contributors
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#pragma once
#ifndef ASIO_STANDALONE
#define ASIO_STANDALONE
#endif//ASIO_STANDALONE
#ifndef USE_STANDALONE_ASIO
#define USE_STANDALONE_ASIO
#endif//ASIO_STANDALONE
#include <algorithm>
#include <fstream>
#include <vector>
#include <memory>
#include <thread>
#include "json/json.h"
#include "simplewebserver/server_http.hpp"
#include "xserver_response_code.h"
#include "xjson_proc.h"
#include "xrule_manager.h"
#include "xaction_manager.h"
#include "xforward_manager.h"
#ifdef HAVE_OPENSSL
#include "crypto.hpp"
#endif
namespace top
{
namespace httpserver
{
using namespace std;
using HttpServer = SimpleWeb::Server<SimpleWeb::HTTP>;
class xforward_msg_handler;
class xhttp_server
{
public:
void start(uint16_t nPort, uint32_t nThreadNum = 1);
void start_service(std::shared_ptr<SimpleWeb::ServerBase<SimpleWeb::HTTP>::Response> response, std::shared_ptr<SimpleWeb::ServerBase<SimpleWeb::HTTP>::Request> request);
void forward_msg(std::shared_ptr<SimpleWeb::ServerBase<SimpleWeb::HTTP>::Response> response, std::shared_ptr<SimpleWeb::ServerBase<SimpleWeb::HTTP>::Request> request);
bool deal_msg(const std::string& request_content, xjson_proc& json_proc);
~xhttp_server();
private:
HttpServer m_server;
std::thread m_server_thread;
xrule_manager m_rule_mgr;
xaction_manager m_action_mgr;
std::shared_ptr<xforward_msg_handler> m_forward_msg_handler;
};
}
}