summaryrefslogtreecommitdiff
path: root/lib/matrix_app_service_web/set_config_plug.ex
diff options
context:
space:
mode:
Diffstat (limited to 'lib/matrix_app_service_web/set_config_plug.ex')
-rw-r--r--lib/matrix_app_service_web/set_config_plug.ex27
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