diff options
author | Pierre de Lacroix <pierre@pdelacroix.com> | 2020-12-01 13:08:29 +0000 |
---|---|---|
committer | Pierre de Lacroix <pierre@pdelacroix.com> | 2020-12-01 13:08:29 +0000 |
commit | 407d202f4c5a094c5a2e991ab81064e060673905 (patch) | |
tree | 2656048c6d4eb0ea134779a85bb6bd41a1466207 /lib/matrix_app_service/application.ex | |
parent | Update README.md (diff) | |
parent | add endpoint handled by the library (diff) |
Merge branch 'choose_endpoint' into 'master'
add endpoint handled by the libraryCloses #23
See merge request kazarma/matrix_app_service.ex!12
Diffstat (limited to 'lib/matrix_app_service/application.ex')
-rw-r--r-- | lib/matrix_app_service/application.ex | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/lib/matrix_app_service/application.ex b/lib/matrix_app_service/application.ex index 38f65be..383c0f9 100644 --- a/lib/matrix_app_service/application.ex +++ b/lib/matrix_app_service/application.ex @@ -18,9 +18,10 @@ defmodule MatrixAppService.Application do ] children = - if Mix.env() == :test do + if start_endpoint?() do [ - MatrixAppServiceWeb.TestEndpoint + # MatrixAppServiceWeb.Endpoint + {MatrixAppServiceWeb.Endpoint, endpoint_config()} | children ] else @@ -36,10 +37,26 @@ defmodule MatrixAppService.Application do # Tell Phoenix to update the endpoint configuration # whenever the application is updated. def config_change(changed, _new, removed) do - if Application.get_env(:matrix_app_service, :standalone, false) do + if start_endpoint?() do MatrixAppServiceWeb.Endpoint.config_change(changed, removed) end :ok end + + def start_endpoint?() do + Application.get_env(:matrix_app_service, :internal_supervisor, false) + end + + def endpoint_config() do + [ + transaction_adapter: Application.fetch_env!(:matrix_app_service, :transaction_adapter), + room_adapter: Application.fetch_env!(:matrix_app_service, :room_adapter), + user_adapter: Application.fetch_env!(:matrix_app_service, :user_adapter), + homeserver_token: Application.fetch_env!(:matrix_app_service, :homeserver_token), + access_token: Application.fetch_env!(:matrix_app_service, :access_token), + base_url: Application.fetch_env!(:matrix_app_service, :base_url), + path: Application.get_env(:matrix_app_service, :path, "/") + ] + end end |