Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
Merge remote-tracking branch 'cloudant/3318-bypass-vhosts'
  • Loading branch information
rnewson committed Mar 6, 2017
2 parents 63ef337 + f706bb8 commit f99e30c38997e33538493204d5d58ea1a0f62de8
Showing 1 changed file with 19 additions and 0 deletions.
@@ -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.

0 comments on commit f99e30c

Please sign in to comment.