make_url/4 calculates a URL with out the protocol://host:port/ prefix it
returns the form /base/module/function/params given a yaws arg record A,
a module name M, a function name F, and a list of parameters Params.
There may be errors in this code as it was copy and pasted from else
where and modififed here. It may also be be possible to get rid of one
of the reverses or make other optimisations. Consider this a first cut.
Todo: find protocol, host, and port used by client and include in url
add when-clauses to function
Jeff.
------
base(A) ->
L = length(yaws_arg:appmoddata(A)),
lists:reverse(lists:nthtail(L,lists:reverse(yaws_arg:server_path(A)))).
make_url(A, M, F, Params) ->
PStr = lists:foldl(fun(P, Acc) ->
PL = erlydb_base:field_to_iolist(P),
[["/" | PL] | Acc]
end,
[],
lists:reverse(Params)),
io:format("PStr ~p~n", [PStr]),
MStr = erlydb_base:field_to_iolist(M),
FStr = erlydb_base:field_to_iolist(F),
lists:flatten(base(A) ++ "/" ++ MStr ++ "/" ++ FStr ++ PStr).
test_make_url() ->
make_url(A, module, function, [1,2,3]).
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"erlyweb" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/erlyweb?hl=en
-~----------~----~----~----~------~----~------~--~---