endpoint.ex 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. defmodule ToyWeb.Endpoint do
  2. use Phoenix.Endpoint, otp_app: :toy
  3. # The session will be stored in the cookie and signed,
  4. # this means its contents can be read but not tampered with.
  5. # Set :encryption_salt if you would also like to encrypt it.
  6. @session_options [
  7. store: :cookie,
  8. key: "_toy_key",
  9. signing_salt: "vFPi5mwK"
  10. ]
  11. socket "/live", Phoenix.LiveView.Socket, websocket: [connect_info: [session: @session_options]]
  12. # Serve at "/" the static files from "priv/static" directory.
  13. #
  14. # You should set gzip to true if you are running phx.digest
  15. # when deploying your static files in production.
  16. plug Plug.Static,
  17. at: "/",
  18. from: :toy,
  19. gzip: false,
  20. only: ~w(assets fonts images favicon.ico robots.txt)
  21. # Code reloading can be explicitly enabled under the
  22. # :code_reloader configuration of your endpoint.
  23. if code_reloading? do
  24. socket "/phoenix/live_reload/socket", Phoenix.LiveReloader.Socket
  25. plug Phoenix.LiveReloader
  26. plug Phoenix.CodeReloader
  27. plug Phoenix.Ecto.CheckRepoStatus, otp_app: :toy
  28. end
  29. plug Phoenix.LiveDashboard.RequestLogger,
  30. param_key: "request_logger",
  31. cookie_key: "request_logger"
  32. plug Plug.RequestId
  33. plug Plug.Telemetry, event_prefix: [:phoenix, :endpoint]
  34. plug Plug.Parsers,
  35. parsers: [:urlencoded, :multipart, :json],
  36. pass: ["*/*"],
  37. json_decoder: Phoenix.json_library()
  38. plug Plug.MethodOverride
  39. plug Plug.Head
  40. plug Plug.Session, @session_options
  41. plug ToyWeb.Router
  42. end