summaryrefslogtreecommitdiffhomepage
path: root/config.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'config.cpp')
-rw-r--r--config.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/config.cpp b/config.cpp
index 0d1eb34..9468e39 100644
--- a/config.cpp
+++ b/config.cpp
@@ -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) {