logo

pleroma

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

legacy_pleroma_api_rerouter_plug.ex (760B)


  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.Fallback.LegacyPleromaApiRerouterPlug do
  5. alias Pleroma.Web.Endpoint
  6. alias Pleroma.Web.Fallback.RedirectController
  7. def init(opts), do: opts
  8. def call(%{path_info: ["api", "pleroma" | path_info_rest]} = conn, _opts) do
  9. new_path_info = ["api", "v1", "pleroma" | path_info_rest]
  10. new_request_path = Enum.join(new_path_info, "/")
  11. conn
  12. |> Map.merge(%{
  13. path_info: new_path_info,
  14. request_path: new_request_path
  15. })
  16. |> Endpoint.call(conn.params)
  17. end
  18. def call(conn, _opts) do
  19. RedirectController.api_not_implemented(conn, %{})
  20. end
  21. end