Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Phoenix Router Extension
defmodule Nectar.ExtendRouter do
Module.register_attribute(__MODULE__, :defined_routes, accumulate: true)
define_route = fn (route) -> Module.put_attribute(__MODULE__, :defined_routes, route) end
define_route.(quote do: get "/favorites", FavoriteProducts.FavoriteController, :index)
defmacro mount do
@defined_routes
end
end
defmodule Nectar.Router do
...
# Add Route Here
# get "/favorites", FavoriteProducts.FavoriteController, :index
require Nectar.ExtendRouter
Nectar.ExtendRouter.mount
...
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.