summaryrefslogtreecommitdiffhomepage
path: root/config.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'config.cpp')
-rw-r--r--config.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/config.cpp b/config.cpp
index c478265..4e33dfc 100644
--- a/config.cpp
+++ b/config.cpp
@@ -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 "";
+}
+