endpoint.ex 1.62 KB
Newer Older
lain's avatar
lain committed
1
2
3
4
defmodule Pleroma.Web.Endpoint do
  use Phoenix.Endpoint, otp_app: :pleroma

  socket "/socket", Pleroma.Web.UserSocket
lain's avatar
lain committed
5
  socket "/api/v1", Pleroma.Web.MastodonAPI.MastodonSocket
lain's avatar
lain committed
6
7
8
9
10
11

  # Serve at "/" the static files from "priv/static" directory.
  #
  # You should set gzip to true if you are running phoenix.digest
  # when deploying your static files in production.
  plug Plug.Static,
lain's avatar
lain committed
12
    at: "/media", from: "uploads", gzip: false
lain's avatar
lain committed
13
14
  plug Plug.Static,
    at: "/", from: :pleroma,
15
    only: ~w(index.html static finmoji emoji packs sounds instance sw.js)
lain's avatar
lain committed
16
17
18
19
20
21
22

  # Code reloading can be explicitly enabled under the
  # :code_reloader configuration of your endpoint.
  if code_reloading? do
    plug Phoenix.CodeReloader
  end

lain's avatar
lain committed
23
  plug TrailingFormatPlug
lain's avatar
lain committed
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
  plug Plug.RequestId
  plug Plug.Logger

  plug Plug.Parsers,
    parsers: [:urlencoded, :multipart, :json],
    pass: ["*/*"],
    json_decoder: Poison

  plug Plug.MethodOverride
  plug Plug.Head

  # The session will be stored in the cookie and signed,
  # this means its contents can be read but not tampered with.
  # Set :encryption_salt if you would also like to encrypt it.
  plug Plug.Session,
    store: :cookie,
    key: "_pleroma_key",
    signing_salt: "CqaoopA2"

  plug Pleroma.Web.Router

  @doc """
  Dynamically loads configuration from the system environment
  on startup.

  It receives the endpoint configuration from the config files
  and must return the updated configuration.
  """
  def load_from_system_env(config) do
    port = System.get_env("PORT") || raise "expected the PORT environment variable to be set"
    {:ok, Keyword.put(config, :http, [:inet6, port: port])}
  end
end