Restructure router rules
This commit is contained in:
parent
02edff90e7
commit
8696b0fb96
3 changed files with 35 additions and 18 deletions
|
@ -1,4 +1,4 @@
|
|||
defmodule MatrixServerWeb.Client.AuthenticateClientPlug do
|
||||
defmodule MatrixServerWeb.Client.Plug.AuthenticateClient do
|
||||
import MatrixServerWeb.Error
|
||||
import Plug.Conn
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
defmodule MatrixServerWeb.Federation.EventController do
|
||||
use MatrixServerWeb, :controller
|
||||
use MatrixServerWeb.Federation.AuthenticateServer
|
||||
|
||||
def event(conn, %{"event_id" => event_id}) do
|
||||
|
||||
end
|
||||
end
|
|
@ -1,47 +1,52 @@
|
|||
defmodule MatrixServerWeb.Router do
|
||||
use MatrixServerWeb, :router
|
||||
|
||||
alias MatrixServerWeb.Client.AuthenticateClientPlug
|
||||
alias MatrixServerWeb.Client.Plug.AuthenticateClient
|
||||
|
||||
# TODO: might be able to handle malformed JSON with custom body reader:
|
||||
# https://elixirforum.com/t/write-malformed-json-in-the-body-plug/30578/13
|
||||
|
||||
# TODO: Split endpoint into client and federation?
|
||||
|
||||
pipeline :public do
|
||||
plug :accepts, ["json"]
|
||||
end
|
||||
|
||||
pipeline :authenticate_client do
|
||||
plug :accepts, ["json"]
|
||||
plug AuthenticateClientPlug
|
||||
plug AuthenticateClient
|
||||
end
|
||||
|
||||
pipeline :authenticate_server do
|
||||
plug :accepts, ["json"]
|
||||
end
|
||||
|
||||
scope "/_matrix", MatrixServerWeb do
|
||||
# Public client endpoint.
|
||||
scope "/_matrix/client", MatrixServerWeb.Client do
|
||||
pipe_through :public
|
||||
|
||||
scope "/client", Client do
|
||||
scope "/r0" do
|
||||
post "/register", RegisterController, :register
|
||||
get "/register/available", AccountController, :available
|
||||
get "/login", LoginController, :login_types
|
||||
post "/login", LoginController, :login
|
||||
end
|
||||
|
||||
get "/versions", InfoController, :versions
|
||||
scope "/r0" do
|
||||
post "/register", RegisterController, :register
|
||||
get "/register/available", AccountController, :available
|
||||
get "/login", LoginController, :login_types
|
||||
post "/login", LoginController, :login
|
||||
end
|
||||
|
||||
scope "/key/v2", Federation do
|
||||
get "/versions", InfoController, :versions
|
||||
end
|
||||
|
||||
# Public federation endpoint.
|
||||
scope "/_matrix", MatrixServerWeb.Federation do
|
||||
scope "/key/v2" do
|
||||
get "/server", KeyController, :get_signing_keys
|
||||
end
|
||||
end
|
||||
|
||||
scope "/_matrix", MatrixServerWeb.Client do
|
||||
# Authenticated client endpoint.
|
||||
scope "/_matrix/client", MatrixServerWeb.Client do
|
||||
pipe_through :authenticate_client
|
||||
|
||||
scope "/client/r0" do
|
||||
scope "/r0" do
|
||||
get "/account/whoami", AccountController, :whoami
|
||||
post "/logout", AccountController, :logout
|
||||
post "/logout/all", AccountController, :logout_all
|
||||
|
@ -53,10 +58,14 @@ defmodule MatrixServerWeb.Router do
|
|||
end
|
||||
end
|
||||
|
||||
scope "/_matrix", MatrixServerWeb.Federation do
|
||||
# Authenticated federation endpoint.
|
||||
scope "/_matrix/federation", MatrixServerWeb.Federation do
|
||||
pipe_through :authenticate_server
|
||||
|
||||
get "/federation/v1/query/profile", QueryController, :profile
|
||||
scope "/v1" do
|
||||
get "/query/profile", QueryController, :profile
|
||||
get "/event/:event_id", EventController, :event
|
||||
end
|
||||
end
|
||||
|
||||
scope "/", MatrixServerWeb.Client do
|
||||
|
|
Loading…
Reference in a new issue