diff options
Diffstat (limited to 'config.cpp')
-rw-r--r-- | config.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
@@ -215,6 +215,36 @@ std::string Config::DocRoot(const Socket& socket, const std::string& requested_h return result; } +std::string Config::GetPlugin(const Socket& socket, const std::string& requested_host, const std::string& requested_path) const +{ + // TODO: speed this up + std::string host{requested_host}; + std::string result; + + auto pos {host.find(':')}; + if (pos != host.npos) { + host = host.substr(0, pos); + } + + for (const auto& site: m_sites) { + if (std::find(socket.serve_sites.begin(), socket.serve_sites.end(), site.name) != socket.serve_sites.end()) { + for (const auto& m_host: site.hosts) { + if (m_host == host) { + for (const auto& path: site.paths) { + if (boost::starts_with(requested_path, path.requested)) { + const auto& root { path.params.at("plugin")}; + if (root.size() > result.size()) + result = root; + } + } + } + } + } + } + + return result; +} + bool Config::PluginIsConfigured(const std::string& name) const { for (const auto& site: m_sites) { |