Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %% dispatch.conf
- %% {["_env", '*'], wmdemo_resource, []}.
- -module(wmdemo_resource).
- -export([init/1, to_json/2, content_types_provided/2]).
- -include_lib("webmachine/include/webmachine.hrl").
- init([]) -> {ok, x}.
- os_env_list(L) -> os_env_list(L,[]).
- os_env_list([],L)-> L;
- os_env_list([H|T], L) ->
- case os:getenv(H) of
- false ->
- os_env_list(T,L);
- Val ->
- D = {H,Val},
- A = lists:append([L,[D]]),
- os_env_list(T,A)
- end.
- get_vars(Path) ->
- string:tokens(string:to_upper(Path),"/").
- to_json(RD,X) ->
- L = os_env_list(get_vars(wrq:path(RD))),
- JSON = mochijson:encode({struct, L}),
- {JSON, RD, X}.
- content_types_provided(RD,X) ->
- {[{"application/json", to_json},{"text/plain", to_json}], RD, X}.
Add Comment
Please, Sign In to add comment