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