Phoenix: Rename Router.Helpers module to Router.Routes

Created on 17 Apr 2018  路  3Comments  路  Source: phoenixframework/phoenix

Note this is for Phoenix v2.0 (which is not coming any time soon and has no due date).

Most helpful comment

Hi @sheharyarn, please note that we won't be able to merge the PR because this change is for Phoenix v2.0 and we have absolutely no plans to work on v2.0 by now. Which means that, by the time we can actually merge it, it will likely be out of date anyway. In any case, thanks for your contributions, but please wait on any issue tagged for 2.0!

All 3 comments

Hi @sheharyarn, please note that we won't be able to merge the PR because this change is for Phoenix v2.0 and we have absolutely no plans to work on v2.0 by now. Which means that, by the time we can actually merge it, it will likely be out of date anyway. In any case, thanks for your contributions, but please wait on any issue tagged for 2.0!

I believe there's a backwards compatible way to approach this, and it is to:

  1. Add a :routes_module or similar option to Phoenix.Router.__using__/1, it would default to <Router>.Helpers.

  2. Change generators so that _new_ apps get:

    defmodule MyApp.Router do
     use MyApp.Web, :router, routes_module: __MODULE__.Routes # or this could聽be in MyApp.Web.router/1 instead.
    end
    

Existing apps will continue to work unchanged. And on Phoenix 2.0, the default for :routes_module will change to <Router>.Routes and the option could be deprecated. But keeping the option post-2.0 could be good too as a matter of explicitness, instead of the Routes module magically appearing, we'd have a reference to it in the code.

What's nice about this is new apps created _soon_ would follow the new convention (and thus less work when upgrading to Phoenix v2.0, though the work required is minuscule). But then again I believe there are still no plans for v2.0 so it's probably not worth the effort until there are!

Was this page helpful?
0 / 5 - 0 ratings