summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Gleason <alex@alexgleason.me>2021-05-21 14:47:11 -0500
committerAlex Gleason <alex@alexgleason.me>2021-05-28 13:51:01 -0500
commitc23b81e399d5be6fc30f4acb1d757d5eb291d8e1 (patch)
treeaef336e394edecf5c565d5f3d2584555e151c9eb
parentb221d77a6da07c684bdbc63ddf4500e0d7ffeae8 (diff)
Pleroma.Web.get_api_routes/0 --> Pleroma.Web.Router.get_api_routes/0
Reduce recompilation time by breaking compile-time cycles
-rw-r--r--lib/pleroma/web.ex12
-rw-r--r--lib/pleroma/web/plugs/frontend_static.ex2
-rw-r--r--lib/pleroma/web/router.ex12
-rw-r--r--test/pleroma/web/plugs/frontend_static_plug_test.exs2
4 files changed, 14 insertions, 14 deletions
diff --git a/lib/pleroma/web.ex b/lib/pleroma/web.ex
index 8630f244b..f1f9d6229 100644
--- a/lib/pleroma/web.ex
+++ b/lib/pleroma/web.ex
@@ -233,16 +233,4 @@ defmodule Pleroma.Web do
def base_url do
Pleroma.Web.Endpoint.url()
end
-
- # TODO: Change to Phoenix.Router.routes/1 for Phoenix 1.6.0+
- def get_api_routes do
- Pleroma.Web.Router.__routes__()
- |> Enum.reject(fn r -> r.plug == Pleroma.Web.Fallback.RedirectController end)
- |> Enum.map(fn r ->
- r.path
- |> String.split("/", trim: true)
- |> List.first()
- end)
- |> Enum.uniq()
- end
end
diff --git a/lib/pleroma/web/plugs/frontend_static.ex b/lib/pleroma/web/plugs/frontend_static.ex
index eb385e94d..e7c943b41 100644
--- a/lib/pleroma/web/plugs/frontend_static.ex
+++ b/lib/pleroma/web/plugs/frontend_static.ex
@@ -10,7 +10,7 @@ defmodule Pleroma.Web.Plugs.FrontendStatic do
"""
@behaviour Plug
- @api_routes Pleroma.Web.get_api_routes()
+ @api_routes Pleroma.Web.Router.get_api_routes()
def file_path(path, frontend_type \\ :primary) do
if configuration = Pleroma.Config.get([:frontends, frontend_type]) do
diff --git a/lib/pleroma/web/router.ex b/lib/pleroma/web/router.ex
index 72ad14f05..3550088bb 100644
--- a/lib/pleroma/web/router.ex
+++ b/lib/pleroma/web/router.ex
@@ -821,4 +821,16 @@ defmodule Pleroma.Web.Router do
options("/*path", RedirectController, :empty)
end
+
+ # TODO: Change to Phoenix.Router.routes/1 for Phoenix 1.6.0+
+ def get_api_routes do
+ __MODULE__.__routes__()
+ |> Enum.reject(fn r -> r.plug == Pleroma.Web.Fallback.RedirectController end)
+ |> Enum.map(fn r ->
+ r.path
+ |> String.split("/", trim: true)
+ |> List.first()
+ end)
+ |> Enum.uniq()
+ end
end
diff --git a/test/pleroma/web/plugs/frontend_static_plug_test.exs b/test/pleroma/web/plugs/frontend_static_plug_test.exs
index 100b83d6a..4152cdefe 100644
--- a/test/pleroma/web/plugs/frontend_static_plug_test.exs
+++ b/test/pleroma/web/plugs/frontend_static_plug_test.exs
@@ -103,6 +103,6 @@ defmodule Pleroma.Web.Plugs.FrontendStaticPlugTest do
"check_password"
]
- assert expected_routes == Pleroma.Web.get_api_routes()
+ assert expected_routes == Pleroma.Web.Router.get_api_routes()
end
end