smpallen99/coherence

Custom url path for controller actions

Open

#292 ouverte le 9 oct. 2017

Voir sur GitHub
 (6 commentaires) (0 réactions) (0 assignés)Elixir (220 forks)batch import
enhancementhelp wanted

Métriques du dépôt

Stars
 (1 259 stars)
Métriques de merge PR
 (Aucune PR mergée en 30 j)

Description

The issue: when developing in phoenix (phx) we want to have a custom path for our Coherence resources. But we currently can't.

In the current file lib/router.ex the resource paths are hardcoded, instead we can have them as default arguments to that they can be customized in each project.

For example:

defmodule Coherence.Router do
...
defmacro coherence_routes(mode \\ [], opts \\ []) do # <--- we have an opportunity here
  ....
  if Coherence.Config.has_action?(:registerable, :new) do
    get "/registrations/new", Coherence.RegistrationController, :new
  end

# And we use this macro in our Phx router as: 
coherence_routes()

While we could do something like this:

defmodule Coherence.Router do
...
defmacro coherence_routes(mode \\ [], opts \\ [:registrations_path: "registrations", ...]) do 
  ....
  if Coherence.Config.has_action?(:registerable, :new) do
    get "/#{opts[:registrations_path]}/new", Coherence.RegistrationController, :new
  end

# And we use this macro in our Phx router as: 
coherence_routes([], [:registrations_path: "accounts"])

I could prepare and open a PR to address that 👍 What do you think?

Guide contributeur