1 defmodule Pleroma.Web.Endpoint do
2 use Phoenix.Endpoint, otp_app: :pleroma
4 if Application.get_env(:pleroma, :chat) |> Keyword.get(:enabled) do
5 socket("/socket", Pleroma.Web.UserSocket)
8 socket("/api/v1", Pleroma.Web.MastodonAPI.MastodonSocket)
10 # Serve at "/" the static files from "priv/static" directory.
12 # You should set gzip to true if you are running phoenix.digest
13 # when deploying your static files in production.
14 plug(Plug.Static, at: "/media", from: Pleroma.Uploaders.Local.upload_path(), gzip: false)
20 only: ~w(index.html static finmoji emoji packs sounds images instance sw.js favicon.png)
23 # Code reloading can be explicitly enabled under the
24 # :code_reloader configuration of your endpoint.
26 plug(Phoenix.CodeReloader)
29 plug(TrailingFormatPlug)
35 parsers: [:urlencoded, :multipart, :json],
38 length: Application.get_env(:pleroma, :instance) |> Keyword.get(:upload_limit),
39 body_reader: {Pleroma.Web.Plugs.DigestPlug, :read_body, []}
42 plug(Plug.MethodOverride)
45 # The session will be stored in the cookie and signed,
46 # this means its contents can be read but not tampered with.
47 # Set :encryption_salt if you would also like to encrypt it.
52 signing_salt: "CqaoopA2"
55 plug(Pleroma.Web.Router)
58 Dynamically loads configuration from the system environment
61 It receives the endpoint configuration from the config files
62 and must return the updated configuration.
64 def load_from_system_env(config) do
65 port = System.get_env("PORT") || raise "expected the PORT environment variable to be set"
66 {:ok, Keyword.put(config, :http, [:inet6, port: port])}