From 0d157fb407a35f8afe6d6f0f4c2cc5cd5d5a1933 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Thu, 9 Apr 2020 18:30:32 +0200 Subject: Prepared generate_page for static-files plugin --- server.cpp | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'server.cpp') diff --git a/server.cpp b/server.cpp index 91ee9e8..47c50ac 100644 --- a/server.cpp +++ b/server.cpp @@ -21,7 +21,11 @@ namespace net = boost::asio; // from namespace ssl = boost::asio::ssl; // from using tcp = boost::asio::ip::tcp; // from -Server::Server(Config& config, boost::asio::io_context& ioc): m_config(config), m_ioc(ioc) +Server::Server(Config& config, boost::asio::io_context& ioc, const Socket& socket, plugins_container_type& plugins) + : m_config(config) + , m_ioc(ioc) + , m_socket(socket) + , m_plugins(plugins) { } @@ -29,7 +33,7 @@ Server::~Server() { } -int server(Config& config) +int run_server(Config& config, plugins_container_type& plugins) { auto const threads = std::max(1, config.Threads()); @@ -40,9 +44,9 @@ int server(Config& config) const auto& sockets {config.Sockets()}; for (const auto& socket: sockets) { if (socket.protocol == SocketProtocol::HTTP) { - servers.push_back(std::make_shared(config, ioc, socket)); + servers.push_back(std::make_shared(config, ioc, socket, plugins)); } else { - servers.push_back(std::make_shared(config, ioc, socket)); + servers.push_back(std::make_shared(config, ioc, socket, plugins)); } servers.back()->start(); } @@ -64,3 +68,18 @@ int server(Config& config) return EXIT_SUCCESS; } +Config& Server::GetConfig() +{ + return m_config; +} + +const Socket& Server::GetSocket() +{ + return m_socket; +} + +plugin_type Server::GetPlugin(const std::string& name) +{ + return m_plugins.at(name); // Config validation made sure that we will find it here. For safety, a thrown exception will be caught in webserver.cpp +} + -- cgit v1.2.3