InstanceStatic: Refactor.

This commit is contained in:
lain 2020-07-28 15:44:47 +02:00
parent 68b3372345
commit 14c28dcbd1

View File

@ -26,18 +26,14 @@ defmodule Pleroma.Plugs.InstanceStatic do
def init(opts) do def init(opts) do
opts opts
|> Keyword.put(:from, "__unconfigured_instance_static_plug") |> Keyword.put(:from, "__unconfigured_instance_static_plug")
|> Keyword.put(:at, "/__unconfigured_instance_static_plug")
|> Plug.Static.init() |> Plug.Static.init()
end end
for only <- Pleroma.Constants.static_only_files() do for only <- Pleroma.Constants.static_only_files() do
at = Plug.Router.Utils.split("/")
def call(%{request_path: "/" <> unquote(only) <> _} = conn, opts) do def call(%{request_path: "/" <> unquote(only) <> _} = conn, opts) do
call_static( call_static(
conn, conn,
opts, opts,
unquote(at),
Pleroma.Config.get([:instance, :static_dir], "instance/static") Pleroma.Config.get([:instance, :static_dir], "instance/static")
) )
end end
@ -47,11 +43,10 @@ defmodule Pleroma.Plugs.InstanceStatic do
conn conn
end end
defp call_static(conn, opts, at, from) do defp call_static(conn, opts, from) do
opts = opts =
opts opts
|> Map.put(:from, from) |> Map.put(:from, from)
|> Map.put(:at, at)
Plug.Static.call(conn, opts) Plug.Static.call(conn, opts)
end end