router.ex 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. defmodule ToyWeb.Router do
  2. use ToyWeb, :router
  3. pipeline :browser do
  4. plug :accepts, ["html"]
  5. plug :fetch_session
  6. plug :fetch_live_flash
  7. plug :put_root_layout, {ToyWeb.LayoutView, :root}
  8. plug :protect_from_forgery
  9. plug :put_secure_browser_headers
  10. end
  11. pipeline :api do
  12. plug :accepts, ["json"]
  13. end
  14. scope "/", ToyWeb do
  15. pipe_through :browser
  16. live "/", PageLive, :index
  17. end
  18. # Other scopes may use custom stacks.
  19. # scope "/api", ToyWeb do
  20. # pipe_through :api
  21. # end
  22. # Enables LiveDashboard only for development
  23. #
  24. # If you want to use the LiveDashboard in production, you should put
  25. # it behind authentication and allow only admins to access it.
  26. # If your application does not have an admins-only section yet,
  27. # you can use Plug.BasicAuth to set up some basic authentication
  28. # as long as you are also using SSL (which you should anyway).
  29. if Mix.env() in [:dev, :test] do
  30. import Phoenix.LiveDashboard.Router
  31. scope "/" do
  32. pipe_through :browser
  33. live_dashboard "/dashboard", metrics: ToyWeb.Telemetry
  34. end
  35. end
  36. end