diff options
author | Roland Reichwein <mail@reichwein.it> | 2020-04-04 20:09:04 +0200 |
---|---|---|
committer | Roland Reichwein <mail@reichwein.it> | 2020-04-04 20:09:04 +0200 |
commit | cbfc28a946ded64e9402e1e6d32511150339ec72 (patch) | |
tree | bec1e30fdd97e99e88a7b168f3cad7278b59157e /config.cpp | |
parent | 1fcaed7a34cce8e55bb071d503bb583f715e7d37 (diff) |
Prepare DocRoot(), WIP
Diffstat (limited to 'config.cpp')
-rw-r--r-- | config.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
@@ -1,5 +1,6 @@ #include "config.h" +#include <boost/algorithm/string/predicate.hpp> #include <boost/property_tree/ptree.hpp> #include <boost/property_tree/xml_parser.hpp> @@ -181,3 +182,30 @@ void Config::dump() const std::cout << "=============================================" << std::endl; } +std::string Config::DocRoot(const Socket& socket, const std::string& requested_host, const std::string& requested_path) +{ + // TODO: speed this up + std::string host{requested_host}; + + 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)) { + return path.params.at("target"); + } + } + } + } + } + } + + return ""; +} + |