summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfeld <feld@feld.me>2021-06-01 16:19:41 +0000
committerfeld <feld@feld.me>2021-06-01 16:19:41 +0000
commit75b94a2f352ea255b0785d0f3ba2c849c8355e04 (patch)
tree96f21ea80b7a8a533a1636392def01408c53cce0
parent0ddf492c5d65559adceac3a78b0a648d09292c86 (diff)
parent595bca24ad79bf058ea6319f26b1ef643e6b7a10 (diff)
Merge branch 'cycles-frontend-static' into 'develop'
Recompilation speedup: make Router a runtime dep of FrontendStatic See merge request pleroma/pleroma!3429
-rw-r--r--lib/pleroma/web/plugs/frontend_static.ex9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/pleroma/web/plugs/frontend_static.ex b/lib/pleroma/web/plugs/frontend_static.ex
index e7c943b41..ebe7eaf86 100644
--- a/lib/pleroma/web/plugs/frontend_static.ex
+++ b/lib/pleroma/web/plugs/frontend_static.ex
@@ -10,8 +10,6 @@ defmodule Pleroma.Web.Plugs.FrontendStatic do
"""
@behaviour Plug
- @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
instance_static_path = Pleroma.Config.get([:instance, :static_dir], "instance/static")
@@ -55,10 +53,13 @@ defmodule Pleroma.Web.Plugs.FrontendStatic do
defp invalid_path?([h | t], match), do: String.contains?(h, match) or invalid_path?(t)
defp invalid_path?([], _match), do: false
- defp api_route?([h | _]) when h in @api_routes, do: true
- defp api_route?([_ | t]), do: api_route?(t)
defp api_route?([]), do: false
+ defp api_route?([h | t]) do
+ api_routes = Pleroma.Web.Router.get_api_routes()
+ if h in api_routes, do: true, else: api_route?(t)
+ end
+
defp call_static(conn, opts, from) do
opts = Map.put(opts, :from, from)
Plug.Static.call(conn, opts)