summaryrefslogtreecommitdiff
path: root/lib/pleroma/plugs/parsers_plug.ex
blob: 2e493ce0e87d02ca580295b5ebfa41e2eecd4a64 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# Pleroma: A lightweight social networking server
# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

defmodule Pleroma.Plugs.Parsers do
  @moduledoc "Initializes Plug.Parsers with upload limit set at boot time"

  @behaviour Plug

  def init(_opts) do
    Plug.Parsers.init(
      parsers: [:urlencoded, :multipart, :json],
      pass: ["*/*"],
      json_decoder: Jason,
      length: Pleroma.Config.get([:instance, :upload_limit]),
      body_reader: {Pleroma.Web.Plugs.DigestPlug, :read_body, []}
    )
  end

  defdelegate call(conn, opts), to: Plug.Parsers
end