diff options
Diffstat (limited to 'lib/matrix_app_service.ex')
-rw-r--r-- | lib/matrix_app_service.ex | 70 |
1 files changed, 58 insertions, 12 deletions
diff --git a/lib/matrix_app_service.ex b/lib/matrix_app_service.ex index 37697a0..a14fdc6 100644 --- a/lib/matrix_app_service.ex +++ b/lib/matrix_app_service.ex @@ -9,23 +9,13 @@ defmodule MatrixAppService do ``` defp deps do - [...] + # ..., {:matrix_app_service, "~> 0.1.0"} end ``` ## Usage - ### Inject routes - - In your Phoenix Router: - - ``` - require MatrixAppServiceWeb.Router - - MatrixAppServiceWeb.Router.routes() - ``` - ### Write adapters Create one or multiple modules that implement the following modules: @@ -59,10 +49,66 @@ defmodule MatrixAppService do end ``` - ### Write configuration + ### Configure + + #### Option 1: Using the :matrix_app_service supervision tree + + Configuration: ``` config :matrix_app_service, + internal_supervisor: true, + transaction_adapter: App.Matrix.Transaction, + room_adapter: App.Matrix.Room, + user_adapter: App.Matrix.User, + path: "/matrix" + base_url: "http://synapse:8008", + access_token: "access token", + homeserver_token: "homeserver token" + ``` + + #### Option 2: Using the :matrix_app_service endpoint in your own supervision tree + + In your application module: + + ``` + children = [ + # ..., + {MatrixAppServiceWeb.Endpoint, app_service_config()} + ] + + # ... + + defp app_service_config(), do: Application.get_env(:app, :app_service) + ``` + + Configuration: + + ``` + config :app, :app_service, + transaction_adapter: App.Matrix.Transaction, + room_adapter: App.Matrix.Room, + user_adapter: App.Matrix.User, + path: "/matrix" + base_url: "http://synapse:8008", + access_token: "access token", + homeserver_token: "homeserver token" + ``` + + #### Option 3: Using your own endpoint + + In your Phoenix Router: + + ``` + use MatrixAppServiceWeb.Routes + + MatrixAppServiceWeb.Routes.routes(Application.get_env(:app, :app_service)) + ``` + + Configuration: + + ``` + config :app, :app_service, transaction_adapter: App.Matrix.Transaction, room_adapter: App.Matrix.Room, user_adapter: App.Matrix.User, |