yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
http_server.h
Go to the documentation of this file.
1#ifndef YAZE_SRC_CLI_SERVICE_API_HTTP_SERVER_H_
2#define YAZE_SRC_CLI_SERVICE_API_HTTP_SERVER_H_
3
4#include <atomic>
5#include <memory>
6#include <string>
7#include <thread>
8
9#include "absl/status/status.h"
10
11// Forward declaration
12namespace httplib {
13class Server;
14}
15
16namespace yaze {
17namespace cli {
18namespace api {
19
21 public:
22 HttpServer();
24
25 // Start the server on the specified port in a background thread.
26 absl::Status Start(int port);
27
28 // Stop the server.
29 void Stop();
30
31 // Check if server is running
32 bool IsRunning() const;
33
34 private:
35 void RunServer(int port);
36 void RegisterRoutes();
37
38 std::unique_ptr<httplib::Server> server_;
39 std::unique_ptr<std::thread> server_thread_;
40 std::atomic<bool> is_running_{false};
41};
42
43} // namespace api
44} // namespace cli
45} // namespace yaze
46
47#endif // YAZE_SRC_CLI_SERVICE_API_HTTP_SERVER_H_
std::unique_ptr< httplib::Server > server_
Definition http_server.h:38
absl::Status Start(int port)
std::unique_ptr< std::thread > server_thread_
Definition http_server.h:39
std::atomic< bool > is_running_
Definition http_server.h:40