Ruby on Rails comes with the terminal command rake routes
. Is there an equivalent in Phoenix?
The command is $ mix phoenix.routes
As @Martimatix pointed out $ mix phx.routes
print all routes for the default router, here's the documentation
This is an example of routes generated for this router.ex
file:
defmodule MessageApi.Router do
use MessageApi.Web, :router
pipeline :api do
plug :accepts, ["json"]
end
scope "/api", MessageApi do
pipe_through :api
resources "/messages", MessageController, except: [:new, :edit]
resources "/message_details", MessageDetailController, except: [:new, :edit]
end
end
then routes generated will be:
message_path GET /api/messages MessageApi.MessageController :index
message_path GET /api/messages/:id MessageApi.MessageController :show
message_path POST /api/messages MessageApi.MessageController :create
message_path PATCH /api/messages/:id MessageApi.MessageController :update
PUT /api/messages/:id MessageApi.MessageController :update
message_path DELETE /api/messages/:id MessageApi.MessageController :delete
message_detail_path GET /api/message_details MessageApi.MessageDetailController :index
message_detail_path GET /api/message_details/:id MessageApi.MessageDetailController :show
message_detail_path POST /api/message_details MessageApi.MessageDetailController :create
message_detail_path PATCH /api/message_details/:id MessageApi.MessageDetailController :update
PUT /api/message_details/:id MessageApi.MessageDetailController :update
message_detail_path DELETE /api/message_details/:id MessageApi.MessageDetailController :delete
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With