summaryrefslogtreecommitdiff
path: root/lib/pleroma/web.ex
diff options
context:
space:
mode:
authorMark Felder <feld@feld.me>2021-02-24 15:23:45 -0600
committerMark Felder <feld@feld.me>2021-02-24 15:27:53 -0600
commitcea31df6a6e0e38ec6a260de0b6ae00d4d40c538 (patch)
tree400ec03724aee0c53f81a8fad958f952ae84a7d0 /lib/pleroma/web.ex
parent6b6791f911748b9881ae1c569f24259cdf11a2b3 (diff)
Attempt to filter out API calls from FrontendStatic plug
Diffstat (limited to 'lib/pleroma/web.ex')
-rw-r--r--lib/pleroma/web.ex14
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/pleroma/web.ex b/lib/pleroma/web.ex
index c3aa39492..fe2652ac9 100644
--- a/lib/pleroma/web.ex
+++ b/lib/pleroma/web.ex
@@ -63,7 +63,8 @@ defmodule Pleroma.Web do
# Executed just before actual controller action, invokes before-action hooks (callbacks)
defp action(conn, params) do
- with %{halted: false} = conn <- maybe_drop_authentication_if_oauth_check_ignored(conn),
+ with %{halted: false} = conn <-
+ maybe_drop_authentication_if_oauth_check_ignored(conn),
%{halted: false} = conn <- maybe_perform_public_or_authenticated_check(conn),
%{halted: false} = conn <- maybe_perform_authenticated_check(conn),
%{halted: false} = conn <- maybe_halt_on_missing_oauth_scopes_check(conn) do
@@ -232,4 +233,15 @@ defmodule Pleroma.Web do
def base_url do
Pleroma.Web.Endpoint.url()
end
+
+ def get_api_routes do
+ Pleroma.Web.Router.__routes__()
+ |> Stream.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