couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject [07/36] couch commit: updated refs/heads/COUCHDB-3287-pluggable-storage-engines to 0fbcd0c
Date Thu, 06 Apr 2017 16:16:21 GMT
Efficiently bypass vhost handling if there are none

COUCHDB-3318


Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch/commit/f706bb87
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch/tree/f706bb87
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch/diff/f706bb87

Branch: refs/heads/COUCHDB-3287-pluggable-storage-engines
Commit: f706bb87be71006875c2fbaed3a14a18c79396f8
Parents: 38d5180
Author: Robert Newson <rnewson@apache.org>
Authored: Mon Mar 6 12:05:33 2017 +0000
Committer: Robert Newson <rnewson@apache.org>
Committed: Mon Mar 6 12:05:33 2017 +0000

----------------------------------------------------------------------
 src/couch_httpd_vhost.erl | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/f706bb87/src/couch_httpd_vhost.erl
----------------------------------------------------------------------
diff --git a/src/couch_httpd_vhost.erl b/src/couch_httpd_vhost.erl
index 91a2476..f23f41d 100644
--- a/src/couch_httpd_vhost.erl
+++ b/src/couch_httpd_vhost.erl
@@ -96,6 +96,14 @@ get_state() ->
 %% @doc Try to find a rule matching current Host heade. some rule is
 %% found it rewrite the Mochiweb Request else it return current Request.
 dispatch_host(MochiReq) ->
+    case vhost_enabled() of
+        true ->
+            dispatch_host_int(MochiReq);
+        false ->
+            MochiReq
+    end.
+
+dispatch_host_int(MochiReq) ->
     #vhosts_state{
         vhost_globals = VHostGlobals,
         vhosts = VHosts,
@@ -398,3 +406,14 @@ load_conf() ->
             "redirect_vhost_handler", DefaultVHostFun)),
 
     {VHostGlobals, VHosts, Fun}.
+
+%% cheaply determine if there are any virtual hosts
+%% configured at all.
+vhost_enabled() ->
+    case {config:get("httpd", "vhost_global_handlers"),
+          config:get("vhosts")} of
+        {undefined, []} ->
+            false;
+        _ ->
+            true
+    end.


Mime
View raw message