Permalink
Browse files

Support for the statistics option per virtual host

  • Loading branch information...
oliv3 committed Jun 10, 2009
1 parent bd62a8c commit 8c969fec53b2b456b455672b09206e565d1e807b
Showing with 18 additions and 2 deletions.
  1. +7 −2 include/yaws.hrl
  2. +11 −0 src/yaws_config.erl
View
@@ -105,6 +105,7 @@
%% flags for sconfs
-define(SC_ACCESS_LOG, 1).
-define(SC_ADD_PORT, 2).
+-define(SC_STATISTICS, 4).
-define(SC_TILDE_EXPAND, 8).
-define(SC_DIR_LISTINGS, 16).
-define(SC_DEFLATE, 32).
@@ -117,6 +118,8 @@
(((SC)#sconf.flags band ?SC_ACCESS_LOG) /= 0)).
-define(sc_has_add_port(SC),
(((SC)#sconf.flags band ?SC_ADD_PORT) /= 0)).
+-define(sc_has_statistics(SC),
+ (((SC)#sconf.flags band ?SC_STATISTICS) /= 0)).
-define(sc_has_tilde_expand(SC),
(((SC)#sconf.flags band ?SC_TILDE_EXPAND) /= 0)).
-define(sc_has_dir_listings(SC),
@@ -133,8 +136,10 @@
SC#sconf{flags = yaws:flag(SC#sconf.flags, ?SC_ACCESS_LOG, Bool)}).
-define(sc_set_add_port(SC, Bool),
SC#sconf{flags = yaws:flag(SC#sconf.flags, ?SC_ADD_PORT, Bool)}).
+-define(sc_set_statistics(SC, Bool),
+ SC#sconf{flags = yaws:flag(SC#sconf.flags, ?SC_STATISTICS, Bool)}).
-define(sc_set_ssl(SC, Bool),
- SC#sconf{flags = yaws:flag(SC#sconf.flags , ?SC_SSL, Bool)}).
+ SC#sconf{flags = yaws:flag(SC#sconf.flags, ?SC_SSL, Bool)}).
-define(sc_set_tilde_expand(SC, Bool),
SC#sconf{flags = yaws:flag(SC#sconf.flags, ?SC_TILDE_EXPAND, Bool)}).
-define(sc_set_dir_listings(SC, Bool),
@@ -178,7 +183,7 @@
revproxy = [],
soptions = [],
extra_cgi_vars = [],
-
+ stats, %% raw traffic statistics
%% [{Extension:string(), Mod:atom()]
%% work in progress .....
extension_mods = [{"ys", yaws_ext_handler_yaws}]
View
@@ -951,8 +951,19 @@ fload(FD, server, GC, C, Cs, Lno, Chars) ->
_URL ->
{error, "Can't revproxy to an URL with a path "}
end;
+
['<', "extra_cgi_vars", "dir", '=', Dir, '>'] ->
fload(FD, extra_cgi_vars, GC, C, Cs, Lno+1, Next, {Dir, []});
+
+ ["statistics", '=', Bool] ->
+ case is_bool(Bool) of
+ {true, Val} ->
+ C2 = ?sc_set_statistics(C, Val),
+ fload(FD, server, GC, C2, Cs, Lno+1, Next);
+ false ->
+ {error, ?F("Expect true|false at line ~w", [Lno])}
+ end;
+
[H|T] ->
{error, ?F("Unexpected input ~p at line ~w", [[H|T], Lno])}
end;

0 comments on commit 8c969fe

Please sign in to comment.