summaryrefslogtreecommitdiffhomepage
path: root/config.cpp
diff options
context:
space:
mode:
authorRoland Reichwein <mail@reichwein.it>2020-04-04 20:09:04 +0200
committerRoland Reichwein <mail@reichwein.it>2020-04-04 20:09:04 +0200
commitcbfc28a946ded64e9402e1e6d32511150339ec72 (patch)
treebec1e30fdd97e99e88a7b168f3cad7278b59157e /config.cpp
parent1fcaed7a34cce8e55bb071d503bb583f715e7d37 (diff)
Prepare DocRoot(), WIP
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 "";
+}
+