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_web/set_config_plug.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_web/set_config_plug.ex')
-rw-r--r-- | lib/matrix_app_service_web/set_config_plug.ex | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/matrix_app_service_web/set_config_plug.ex b/lib/matrix_app_service_web/set_config_plug.ex new file mode 100644 index 0000000..10296e2 --- /dev/null +++ b/lib/matrix_app_service_web/set_config_plug.ex @@ -0,0 +1,27 @@ +defmodule MatrixAppServiceWeb.SetConfigPlug do + @moduledoc """ + """ + + @behaviour Plug + import Plug.Conn + require Logger + + @doc false + @impl Plug + def init(opts) do + opts + end + + @doc false + @impl Plug + def call(conn, opts) do + conn + |> put_private(:transaction_adapter, Keyword.fetch!(opts, :transaction_adapter)) + |> put_private(:room_adapter, Keyword.fetch!(opts, :room_adapter)) + |> put_private(:user_adapter, Keyword.fetch!(opts, :user_adapter)) + |> put_private(:homeserver_token, Keyword.fetch!(opts, :homeserver_token)) + |> put_private(:access_token, Keyword.fetch!(opts, :access_token)) + |> put_private(:base_url, Keyword.fetch!(opts, :base_url)) + |> put_private(:path, Keyword.fetch!(opts, :path)) + end +end |