Skip to content

Commit

Permalink
added opaque-related utility functions to yaws_arg
Browse files Browse the repository at this point in the history
  • Loading branch information
yarivvv committed Dec 2, 2007
1 parent 1d243f9 commit eb41681
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion src/erlyweb/yaws_arg.erl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
-module(yaws_arg).
-author("Yariv Sadan (yarivsblog@gmail.com)").

-export([new/0, clisock/1, clisock/2, client_ip_port/1, client_ip_port/2,
-export([new/0,
add_to_opaque/2, add_all_to_opaque/2, get_opaque_val/2,
clisock/1, clisock/2, client_ip_port/1, client_ip_port/2,
headers/1, headers/2, req/1, req/2,
method/1, clidata/1, clidata/2, server_path/1, server_path/2,
querydata/1, querydata/2, appmoddata/1, appmoddata/2, docroot/1,
Expand All @@ -33,6 +35,26 @@
new() ->
#arg{}.

%% @equiv Arg#arg{opaque = [Val | A#arg.opaque]}.
add_to_opaque(Arg, Val) ->
Arg#arg{opaque = [Val | Arg#arg.opaque]}.

%% @doc applies add_to_opaque for all values in the list
%%
%% @spec add_all_to_opaque(A::arg(), Vals::[term()])
add_all_to_opaque(A, Vals) ->
lists:foldl(
fun(Val, A1) ->
add_to_opaque(A1, Val)
end, A, Vals).

%% @doc Return the value corrsponding to the Key in the opaque proplist.
%% If the key isn't found, return 'undefined'.
%%
%% @spec get_opaque_val(A::arg(), Key::term()) -> term() | undefined
get_opaque_val(A, Key) ->
proplists:get_value(Key, yaws_arg:opaque(A)).

clisock(Arg) ->
Arg#arg.clisock.

Expand Down

0 comments on commit eb41681

Please sign in to comment.