router.ex 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. defmodule FourlettersWeb.Router do
  2. use FourlettersWeb, :router
  3. pipeline :browser do
  4. plug :accepts, ["html"]
  5. plug :fetch_session
  6. plug :fetch_flash
  7. plug :protect_from_forgery
  8. plug :put_secure_browser_headers
  9. end
  10. pipeline :api do
  11. plug :accepts, ["json"]
  12. end
  13. scope "/", FourlettersWeb do
  14. pipe_through :browser
  15. get "/", FourlettersController, :nothing
  16. get "/:fourletters", FourlettersController, :fourletters
  17. end
  18. # Other scopes may use custom stacks.
  19. scope "/", FourlettersWeb do
  20. pipe_through :api
  21. post "/:fourletters", FourlettersController, :addletters
  22. get "/api/:fourletters", FourlettersController, :getmessages
  23. post "/api/:fourletters", FourlettersController, :apiaddletters
  24. delete "/api/:fourletters", FourlettersController, :clearletters
  25. # for stupid html forms that dont do DELETE
  26. post "/api/clear/:fourletters", FourlettersController, :clearletters
  27. end
  28. # Enables LiveDashboard only for development
  29. #
  30. # If you want to use the LiveDashboard in production, you should put
  31. # it behind authentication and allow only admins to access it.
  32. # If your application does not have an admins-only section yet,
  33. # you can use Plug.BasicAuth to set up some basic authentication
  34. # as long as you are also using SSL (which you should anyway).
  35. if Mix.env() in [:dev, :test] do
  36. import Phoenix.LiveDashboard.Router
  37. scope "/" do
  38. pipe_through :browser
  39. live_dashboard "/dashboard", metrics: FourlettersWeb.Telemetry
  40. end
  41. end
  42. end