summaryrefslogtreecommitdiff
path: root/lib/pleroma/web.ex
diff options
context:
space:
mode:
authorlain <lain@soykaf.club>2021-02-27 19:40:38 +0000
committerlain <lain@soykaf.club>2021-02-27 19:40:38 +0000
commitd0823d7f1e95c91a53545fae9299e5bcc6eaf758 (patch)
treee3c3e89c3abd04a8c6bf5c95d072d335af15e082 /lib/pleroma/web.ex
parentdd937ae625d34033d7a752f914e9b9ff3fb24ae4 (diff)
parent76b166f0401c85df537c13591a7397e2c21732ac (diff)
Merge branch 'frontendstatic-ignore-api-calls' into 'develop'
Filter out API calls from FrontendStatic plug Closes #2261 See merge request pleroma/pleroma!3346
Diffstat (limited to 'lib/pleroma/web.ex')
-rw-r--r--lib/pleroma/web.ex15
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/pleroma/web.ex b/lib/pleroma/web.ex
index c3aa39492..8630f244b 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,16 @@ 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