-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathserver.h
53 lines (38 loc) · 1.13 KB
/
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
42
43
44
45
46
47
48
49
50
51
52
53
#ifndef SERVER_HPP
#define SERVER_HPP
#include <boost/asio.hpp>
#include <string>
#include "connection.h"
#include "request_handler.h"
#include <map>
namespace http {
namespace server {
class server
{
public:
// Does not allow us to make copies of the server
// server(const server&) = delete;
// server& operator=(const server&) = delete;
explicit server(const std::string& address, NginxConfig config);
void run();
bool getStatus();
void do_await_stop();
bool create_connection(boost::system::error_code ec);
std::string getPortNum();
std::string getAddress();
private:
void do_accept();
boost::asio::io_service io_service_;
boost::asio::signal_set signals_;
boost::asio::ip::tcp::acceptor acceptor_;
boost::asio::ip::tcp::socket socket_;
bool isRunning = false;
std::string portNum_;
std::string address_;
std::string fileName_;
/// The handlers for all incoming requests.
std::map <std::string, RequestHandler*> handlers;
};
} // namespace server
} // namespace http
#endif