From 70c1cdfd8f34472761fe5ec97f0713990c1b4f5b Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Wed, 5 Sep 2018 21:23:41 +0300 Subject: Add multi-tenancy support --- mod/mod-repository-root.cxx | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'mod/mod-repository-root.cxx') diff --git a/mod/mod-repository-root.cxx b/mod/mod-repository-root.cxx index 3b0ab1f..b8777fd 100644 --- a/mod/mod-repository-root.cxx +++ b/mod/mod-repository-root.cxx @@ -275,13 +275,27 @@ namespace brep if (!rpath.sub (root)) return false; - const path& lpath (rpath.leaf (root)); + path lpath (rpath.leaf (root)); + + if (!lpath.empty ()) + { + path::iterator i (lpath.begin ()); + const string& s (*i); + + if (s[0] == '@' && s.size () > 1) + { + tenant = string (s, 1); + lpath = path (++i, lpath.end ()); + } + } // Delegate the request handling to the selected sub-handler. Intercept // exception handling to add sub-handler attribution. // - auto handle = [&rq, &rs, this] (const char* nm, bool fn = false) -> bool + auto handle = [&rq, &rs, this] (const char* nm, bool fn = false) { + handler_->tenant = move (tenant); + try { // Delegate the handling straight away if the sub-handler is not a -- cgit v1.1