summaryrefslogtreecommitdiff
path: root/lib/pleroma/web/fallback/legacy_pleroma_api_rerouter_plug.ex
diff options
context:
space:
mode:
authoreugenijm <eugenijm@protonmail.com>2021-02-19 00:59:06 +0300
committereugenijm <eugenijm@protonmail.com>2021-02-21 13:26:23 +0300
commitc1d63bbd9a4f39dbd92811b1720705342e5c914e (patch)
tree1edc3b32d7c1878e8811dd9ff12b35097c5ed949 /lib/pleroma/web/fallback/legacy_pleroma_api_rerouter_plug.ex
parent0edb5c805be97b42a68db1aa5f00c33483a0f035 (diff)
Reroute /api/pleroma to /api/v1/pleroma
Diffstat (limited to 'lib/pleroma/web/fallback/legacy_pleroma_api_rerouter_plug.ex')
-rw-r--r--lib/pleroma/web/fallback/legacy_pleroma_api_rerouter_plug.ex26
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/pleroma/web/fallback/legacy_pleroma_api_rerouter_plug.ex b/lib/pleroma/web/fallback/legacy_pleroma_api_rerouter_plug.ex
new file mode 100644
index 000000000..f86d6b52b
--- /dev/null
+++ b/lib/pleroma/web/fallback/legacy_pleroma_api_rerouter_plug.ex
@@ -0,0 +1,26 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Pleroma.Web.Fallback.LegacyPleromaApiRerouterPlug do
+ alias Pleroma.Web.Endpoint
+ alias Pleroma.Web.Fallback.RedirectController
+
+ def init(opts), do: opts
+
+ def call(%{path_info: ["api", "pleroma" | path_info_rest]} = conn, _opts) do
+ new_path_info = ["api", "v1", "pleroma" | path_info_rest]
+ new_request_path = Enum.join(new_path_info, "/")
+
+ conn
+ |> Map.merge(%{
+ path_info: new_path_info,
+ request_path: new_request_path
+ })
+ |> Endpoint.call(conn.params)
+ end
+
+ def call(conn, _opts) do
+ RedirectController.api_not_implemented(conn, %{})
+ end
+end