-module(myapp_config). -export([ dispatch/0, web_config/0 ]). -spec dispatch() -> [webmachine_dispatcher:route()]. dispatch() -> lists:flatten([ {[], myapp01_resource, [{operation, one}]}, {["docs"], myapp01_doc_resource, [{operation, two}]}, {["docs", recid], myapp01_doc_resource, [{operation, three}]}, {["docs", "delete", recid], myapp01_doc_resource, [{operation, delete}]} ]). web_config() -> {ok, App} = application:get_application(?MODULE), {ok, Ip} = application:get_env(App, web_ip), {ok, Port} = application:get_env(App, web_port), {ok, Tablename} = application:get_env(App, table_name), io:format("(web_config) Port: ~p~n", [Port]), io:format("(web_config) Tablename: ~p~n", [Tablename]), % Create an ETS table and insert the initial ID number. ets:new(Tablename, [set, named_table, public]), ets:insert(doc_table, {current_id, 0}), [ {ip, Ip}, {port, Port}, {log_dir, "priv/log"}, {dispatch, dispatch()} ].