Initial http implementation
This commit is contained in:
22
src/main.cpp
22
src/main.cpp
@@ -1,6 +1,7 @@
|
||||
#include "config.hpp"
|
||||
#include "connection.hpp"
|
||||
#include "connection_handler.hpp"
|
||||
#include "http_handler.hpp"
|
||||
#include "server.hpp"
|
||||
#include <atomic>
|
||||
#include <csignal>
|
||||
@@ -21,21 +22,6 @@ void signal_handler(int sig) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple echo handler that mirrors received data back to the client.
|
||||
*
|
||||
* This implementation preserves the current behavior of the server
|
||||
* while demonstrating the ConnectionHandler interface pattern.
|
||||
*/
|
||||
class EchoHandler : public ConnectionHandler {
|
||||
public:
|
||||
void on_data_arrived(std::string_view data,
|
||||
std::unique_ptr<Connection> &conn_ptr) override {
|
||||
// Echo the received data back to the client
|
||||
conn_ptr->appendMessage(data);
|
||||
}
|
||||
};
|
||||
|
||||
void print_help(const char *program_name) {
|
||||
std::cout << "WeaselDB - High-performance write-side database component\n\n";
|
||||
std::cout << "Usage: " << program_name << " [OPTIONS]\n\n";
|
||||
@@ -121,8 +107,8 @@ int main(int argc, char *argv[]) {
|
||||
<< std::endl;
|
||||
|
||||
// Create handler and server
|
||||
EchoHandler echo_handler;
|
||||
auto server = Server::create(*config, echo_handler);
|
||||
HttpHandler http_handler;
|
||||
auto server = Server::create(*config, http_handler);
|
||||
g_server = server.get();
|
||||
|
||||
// Setup signal handling
|
||||
@@ -130,7 +116,7 @@ int main(int argc, char *argv[]) {
|
||||
signal(SIGTERM, signal_handler);
|
||||
signal(SIGINT, signal_handler);
|
||||
|
||||
std::cout << "Starting WeaselDB server..." << std::endl;
|
||||
std::cout << "Starting WeaselDB HTTP server..." << std::endl;
|
||||
server->run();
|
||||
std::cout << "Server shutdown complete." << std::endl;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user