-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathhttp_server.hpp
More file actions
52 lines (45 loc) · 1.02 KB
/
http_server.hpp
File metadata and controls
52 lines (45 loc) · 1.02 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
51
52
#pragma once
#include "fastmcpp/server/server.hpp"
#include <atomic>
#include <memory>
#include <string>
#include <thread>
namespace httplib
{
class Server;
}
namespace fastmcpp::server
{
class HttpServerWrapper
{
public:
HttpServerWrapper(std::shared_ptr<Server> core, std::string host = "127.0.0.1",
int port = 18080, std::string auth_token = "",
std::string allowed_origin = "", size_t payload_limit = 1024 * 1024);
~HttpServerWrapper();
bool start();
void stop();
bool running() const
{
return running_.load();
}
int port() const
{
return port_;
}
const std::string& host() const
{
return host_;
}
private:
std::shared_ptr<Server> core_;
std::string host_;
int port_;
std::string auth_token_;
std::string allowed_origin_;
size_t payload_limit_;
std::unique_ptr<httplib::Server> svr_;
std::thread thread_;
std::atomic<bool> running_{false};
};
} // namespace fastmcpp::server