defmodule MatrixAppServiceWeb.Router do @moduledoc """ Provides the Matrix Application Service API routes. https://matrix.org/docs/spec/application_service/r0.1.2 """ @doc """ This macro injects the API routes in a Phoenix router. """ defmacro routes() do quote do pipeline :matrix_api do plug :accepts, ["json"] plug MatrixAppServiceWeb.AuthPlug end path = Application.compile_env(:matrix_app_service, :path, "/") scope path, MatrixAppServiceWeb.V1 do pipe_through :matrix_api put "/transactions/:txn_id", TransactionController, :push get "/users/:user_id", UserController, :query get "/rooms/:room_alias", RoomController, :query get "/thirdparty/protocol/:protocol", ThirdPartyController, :query_protocol get "/thirdparty/user/:protocol", ThirdPartyController, :query_users get "/thirdparty/location/:protocol", ThirdPartyController, :query_locations get "/thirdparty/location", ThirdPartyController, :query_location_by_alias get "/thirdparty/user", ThirdPartyController, :query_user_by_id end end end end