diff --git a/config/config.exs b/config/config.exs --- a/config/config.exs +++ b/config/config.exs @@ -28,3 +28,6 @@ # here (which is why it is important to import them last). # # import_config "#{Mix.env}.exs" + +config :kolab_wopi, + chwala_base_url: "http://localhost/chwala/api/" diff --git a/lib/kolab_wopi.ex b/lib/kolab_wopi.ex --- a/lib/kolab_wopi.ex +++ b/lib/kolab_wopi.ex @@ -8,8 +8,7 @@ children = [ # Define workers and child supervisors to be supervised - worker(__MODULE__.API, []), - worker(__MODULE__.Chwala, []) + worker(__MODULE__.API, []) ] # See http://elixir-lang.org/docs/stable/elixir/Supervisor.html diff --git a/lib/kolab_wopi/chwala.ex b/lib/kolab_wopi/chwala.ex --- a/lib/kolab_wopi/chwala.ex +++ b/lib/kolab_wopi/chwala.ex @@ -1,11 +1,8 @@ defmodule KolabWopi.Chwala do - use GenServer use HTTPoison.Base require Logger - @url "http://localhost/chwala/api/" - def start_link do GenServer.start_link(__MODULE__, []) end @@ -40,7 +37,7 @@ # TODO: error handling - response = get!(@url, [], params: params) + response = get!(base_url, [], params: params) response.body end @@ -68,7 +65,7 @@ id: file_id, } - response = get!(@url, [], params: params) + response = get!(base_url, [], params: params) response.body end @@ -101,7 +98,7 @@ # TODO: use streams to pass the file body? - response = put!(@url, body, [], params: params) + response = put!(base_url, body, [], params: params) end @doc """ @@ -138,4 +135,9 @@ |> Poison.decode! |> Enum.map(fn({k, v}) -> {String.to_atom(k), v} end) end + + # Returns the base URL for the chwala implementation + defp base_url() do + Application.get_env(:kolab_wopi, :chwala_base_url) + end end