Skip to content

Instantly share code, notes, and snippets.

@darkofabijan
Last active January 4, 2016 21:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save darkofabijan/8685062 to your computer and use it in GitHub Desktop.
Save darkofabijan/8685062 to your computer and use it in GitHub Desktop.
defmodule MyApp.Router do
use Phoenix.Router
namespace MyApp.Controllers do
get "restaurants/:id", Restaurants, :show, as: :restaurant
resources :images
resources :users, Accounts
end
# it's probably expected that this would prepend "/api" to all specific and resources routes.
namespace MyApp.Controllers.Api do
resources :images
resources :users, Accounts
end
namespace MyApp.Controllers.Admin do
get "accounts/:id", Users, :show, as: :user
delete "accounts/:id", Users, :destroy
resources :restaurants
end
# if namespace nesting is allowed, but question of nesting is already open for resources
namespace MyApp.Controllers do
get "restaurants/:id", Restaurants, :show, as: :restaurant
resources :images
resources :users, Accounts
namespace Api do
resources :images
resources :users, Accounts
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment