2018-10-11 17:37:39 +02:00
|
|
|
defmodule MobilizonWeb.Endpoint do
|
2018-01-14 17:56:50 +01:00
|
|
|
@moduledoc """
|
2018-10-11 17:37:39 +02:00
|
|
|
Endpoint for Mobilizon app
|
2018-01-14 17:56:50 +01:00
|
|
|
"""
|
2018-10-11 17:37:39 +02:00
|
|
|
use Phoenix.Endpoint, otp_app: :mobilizon
|
2017-12-08 09:58:14 +01:00
|
|
|
|
2019-10-05 19:07:50 +02:00
|
|
|
# For e2e tests
|
|
|
|
if Application.get_env(:mobilizon, :sql_sandbox) do
|
|
|
|
plug(Phoenix.Ecto.SQL.Sandbox,
|
|
|
|
at: "/sandbox",
|
|
|
|
header: "x-session-id",
|
|
|
|
repo: Mobilizon.Storage.Repo
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
plug(MobilizonWeb.Plugs.UploadedMedia)
|
|
|
|
|
2017-12-08 09:58:14 +01:00
|
|
|
# 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.
|
2018-07-27 10:45:35 +02:00
|
|
|
plug(
|
|
|
|
Plug.Static,
|
|
|
|
at: "/",
|
2018-10-11 17:37:39 +02:00
|
|
|
from: :mobilizon,
|
2018-07-27 10:45:35 +02:00
|
|
|
gzip: false,
|
2019-04-17 17:13:20 +02:00
|
|
|
only: ~w(css fonts images js favicon.ico robots.txt)
|
2018-07-27 10:45:35 +02:00
|
|
|
)
|
2017-12-08 09:58:14 +01:00
|
|
|
|
|
|
|
# Code reloading can be explicitly enabled under the
|
|
|
|
# :code_reloader configuration of your endpoint.
|
|
|
|
if code_reloading? do
|
2018-07-27 10:45:35 +02:00
|
|
|
socket("/phoenix/live_reload/socket", Phoenix.LiveReloader.Socket)
|
|
|
|
plug(Phoenix.LiveReloader)
|
|
|
|
plug(Phoenix.CodeReloader)
|
2017-12-08 09:58:14 +01:00
|
|
|
end
|
|
|
|
|
2018-07-27 10:45:35 +02:00
|
|
|
plug(CORSPlug)
|
|
|
|
plug(Plug.RequestId)
|
|
|
|
plug(Plug.Logger)
|
2017-12-08 09:58:14 +01:00
|
|
|
|
2018-07-27 10:45:35 +02:00
|
|
|
plug(
|
|
|
|
Plug.Parsers,
|
2019-05-22 14:12:11 +02:00
|
|
|
parsers: [:urlencoded, :multipart, :json, Absinthe.Plug.Parser],
|
2017-12-08 09:58:14 +01:00
|
|
|
pass: ["*/*"],
|
2019-02-14 14:19:55 +01:00
|
|
|
json_decoder: Jason
|
2018-07-27 10:45:35 +02:00
|
|
|
)
|
2017-12-08 09:58:14 +01:00
|
|
|
|
2018-07-27 10:45:35 +02:00
|
|
|
plug(Plug.MethodOverride)
|
|
|
|
plug(Plug.Head)
|
2017-12-08 09:58:14 +01:00
|
|
|
|
|
|
|
# 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.
|
2018-07-27 10:45:35 +02:00
|
|
|
plug(
|
|
|
|
Plug.Session,
|
2017-12-08 09:58:14 +01:00
|
|
|
store: :cookie,
|
2018-10-11 17:37:39 +02:00
|
|
|
key: "_mobilizon_key",
|
2017-12-08 09:58:14 +01:00
|
|
|
signing_salt: "F9CCTF22"
|
2018-07-27 10:45:35 +02:00
|
|
|
)
|
2017-12-08 09:58:14 +01:00
|
|
|
|
2018-10-11 17:37:39 +02:00
|
|
|
plug(MobilizonWeb.Router)
|
2017-12-08 09:58:14 +01:00
|
|
|
end
|