From d1124704f98e1bf1994c91ab6c0110b88ed46377 Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Fri, 7 Oct 2022 18:03:25 +0200 Subject: [PATCH] Make `kiwix::Server` a simple wrapper around `kiwix::InternalServer`. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `kiwix::Server` is now a simple exposition of a public API on top of the private `InternalServer`. --- include/server.h | 9 +++++++-- src/server.cpp | 12 ++---------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/include/server.h b/include/server.h index 0ce613f21..b79c24699 100644 --- a/include/server.h +++ b/include/server.h @@ -104,7 +104,6 @@ namespace kiwix * @param library The library to serve. */ explicit Server(const Configuration& configuration); - virtual ~Server(); /** @@ -122,11 +121,17 @@ namespace kiwix */ bool isRunning(); + /** + * Get the port of the server + */ int getPort(); + + /** + * Get the ipAddress of the server + */ std::string getAddress(); protected: - Configuration m_configuration; std::unique_ptr mp_server; }; } diff --git a/src/server.cpp b/src/server.cpp index 4388f471e..61668f4a5 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -42,29 +42,21 @@ Server::Configuration& Server::Configuration::setRoot(const std::string& root) } Server::Server(const Server::Configuration& configuration) : - m_configuration(configuration), - mp_server(nullptr) + mp_server(new InternalServer(configuration)) { } Server::~Server() = default; bool Server::start() { - mp_server.reset(new InternalServer(m_configuration)); return mp_server->start(); } void Server::stop() { - if (mp_server) { - mp_server->stop(); - mp_server.reset(nullptr); - } + mp_server->stop(); } bool Server::isRunning() { - if (!mp_server) { - return false; - } return mp_server->isRunning(); }