Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the equivalent of rake routes in Phoenix?

Ruby on Rails comes with the terminal command rake routes. Is there an equivalent in Phoenix?

like image 343
Martimatix Avatar asked Feb 12 '16 23:02

Martimatix


2 Answers

The command is $ mix phoenix.routes

like image 108
Martimatix Avatar answered Oct 27 '22 10:10

Martimatix


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
like image 34
Cyzanfar Avatar answered Oct 27 '22 10:10

Cyzanfar