logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://hacktivis.me/git/pleroma.git

trailing_format_plug.ex (1040B)


  1. # Pleroma: A lightweight social networking server
  2. # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
  3. # SPDX-License-Identifier: AGPL-3.0-only
  4. defmodule Pleroma.Web.Plugs.TrailingFormatPlug do
  5. @moduledoc "Calls TrailingFormatPlug for specific paths. Ideally we would just do this in the router, but TrailingFormatPlug needs to be called before Plug.Parsers."
  6. @behaviour Plug
  7. @paths [
  8. "/api/statusnet",
  9. "/api/statuses",
  10. "/api/qvitter",
  11. "/api/search",
  12. "/api/account",
  13. "/api/friends",
  14. "/api/mutes",
  15. "/api/media",
  16. "/api/favorites",
  17. "/api/blocks",
  18. "/api/friendships",
  19. "/api/users",
  20. "/users",
  21. "/nodeinfo",
  22. "/api/help",
  23. "/api/externalprofile",
  24. "/notice",
  25. "/api/pleroma/emoji",
  26. "/api/oauth_tokens"
  27. ]
  28. def init(opts) do
  29. TrailingFormatPlug.init(opts)
  30. end
  31. for path <- @paths do
  32. def call(%{request_path: unquote(path) <> _} = conn, opts) do
  33. TrailingFormatPlug.call(conn, opts)
  34. end
  35. end
  36. def call(conn, _opts), do: conn
  37. end