Pleroma.Web.get_api_routes/0 --> Pleroma.Web.Router.get_api_routes/0
Reduce recompilation time by breaking compile-time cycles
This commit is contained in:
parent
b221d77a6d
commit
c23b81e399
@ -233,16 +233,4 @@ defmodule Pleroma.Web do
|
|||||||
def base_url do
|
def base_url do
|
||||||
Pleroma.Web.Endpoint.url()
|
Pleroma.Web.Endpoint.url()
|
||||||
end
|
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
|
end
|
||||||
|
@ -10,7 +10,7 @@ defmodule Pleroma.Web.Plugs.FrontendStatic do
|
|||||||
"""
|
"""
|
||||||
@behaviour Plug
|
@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
|
def file_path(path, frontend_type \\ :primary) do
|
||||||
if configuration = Pleroma.Config.get([:frontends, frontend_type]) do
|
if configuration = Pleroma.Config.get([:frontends, frontend_type]) do
|
||||||
|
@ -821,4 +821,16 @@ defmodule Pleroma.Web.Router do
|
|||||||
|
|
||||||
options("/*path", RedirectController, :empty)
|
options("/*path", RedirectController, :empty)
|
||||||
end
|
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
|
end
|
||||||
|
@ -103,6 +103,6 @@ defmodule Pleroma.Web.Plugs.FrontendStaticPlugTest do
|
|||||||
"check_password"
|
"check_password"
|
||||||
]
|
]
|
||||||
|
|
||||||
assert expected_routes == Pleroma.Web.get_api_routes()
|
assert expected_routes == Pleroma.Web.Router.get_api_routes()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user