summaryrefslogtreecommitdiffhomepage
path: root/server.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'server.cpp')
-rw-r--r--server.cpp27
1 files changed, 23 insertions, 4 deletions
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 <boost/asio.hpp>
namespace ssl = boost::asio::ssl; // from <boost/asio/ssl.hpp>
using tcp = boost::asio::ip::tcp; // from <boost/asio/ip/tcp.hpp>
-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<int>(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<HTTP::Server>(config, ioc, socket));
+ servers.push_back(std::make_shared<HTTP::Server>(config, ioc, socket, plugins));
} else {
- servers.push_back(std::make_shared<HTTPS::Server>(config, ioc, socket));
+ servers.push_back(std::make_shared<HTTPS::Server>(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
+}
+