diff options
author | Roland Reichwein <mail@reichwein.it> | 2020-04-09 18:30:32 +0200 |
---|---|---|
committer | Roland Reichwein <mail@reichwein.it> | 2020-04-09 18:30:32 +0200 |
commit | 0d157fb407a35f8afe6d6f0f4c2cc5cd5d5a1933 (patch) | |
tree | 86ccea82ebbe29197eacb9a85e8ec7548c5ae38c /config.cpp | |
parent | 2f42619303627db401e469e2fd65123cd794a378 (diff) |
Prepared generate_page for static-files plugin
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) { |