Merge branch 'feature/fix-warnings' into 'develop'
[akkoma] / lib / pleroma / web / endpoint.ex
1 defmodule Pleroma.Web.Endpoint do
2 use Phoenix.Endpoint, otp_app: :pleroma
3
4 socket "/socket", Pleroma.Web.UserSocket
5 socket "/api/v1", Pleroma.Web.MastodonAPI.MastodonSocket
6
7 # Serve at "/" the static files from "priv/static" directory.
8 #
9 # You should set gzip to true if you are running phoenix.digest
10 # when deploying your static files in production.
11 plug Plug.Static,
12 at: "/media", from: "uploads", gzip: false
13 plug Plug.Static,
14 at: "/", from: :pleroma,
15 only: ~w(index.html static finmoji emoji packs sounds sw.js)
16
17 # Code reloading can be explicitly enabled under the
18 # :code_reloader configuration of your endpoint.
19 if code_reloading? do
20 plug Phoenix.CodeReloader
21 end
22
23 plug TrailingFormatPlug
24 plug Plug.RequestId
25 plug Plug.Logger
26
27 plug Plug.Parsers,
28 parsers: [:urlencoded, :multipart, :json],
29 pass: ["*/*"],
30 json_decoder: Poison
31
32 plug Plug.MethodOverride
33 plug Plug.Head
34
35 # The session will be stored in the cookie and signed,
36 # this means its contents can be read but not tampered with.
37 # Set :encryption_salt if you would also like to encrypt it.
38 plug Plug.Session,
39 store: :cookie,
40 key: "_pleroma_key",
41 signing_salt: "CqaoopA2"
42
43 plug Pleroma.Web.Router
44
45 @doc """
46 Dynamically loads configuration from the system environment
47 on startup.
48
49 It receives the endpoint configuration from the config files
50 and must return the updated configuration.
51 """
52 def load_from_system_env(config) do
53 port = System.get_env("PORT") || raise "expected the PORT environment variable to be set"
54 {:ok, Keyword.put(config, :http, [:inet6, port: port])}
55 end
56 end