-
Notifications
You must be signed in to change notification settings - Fork 9
Description
This is sticker than it should be. Phoenix routes to a specific controller but we're using a shared controller approach. Although we can easily change the default resource by overriding Concern.default_page/0, that's only part of the picture. We need to specify the corresponding controller in the router. Further, our load_concern plug expects the resource param loaded by Phoenix router. Without that, it assumes it's a page.
The best way may be a plug that uses the default_page (that may have a page or backed resource) and determines the appropriate controller. See this:
https://elixirforum.com/t/does-router-support-glob-like-a-e/2863/4
It would also have to configure the resource, if needed. I'm not sure it's worth adding more complexity to handle this right now
On a related note, we can consider offloading the root route handling to the target project. This would more easily allow the user to select what page/resource to use for the root route (e.g. /admin) without needing any additional plug/controller handling in Talon. To make this easier for the user, we could generate the router boiler plate as:
scope "/#{route_scope}", #{namespace} do
pipe_through :browser
talon_routes(#{to_s full_concern})
get "/", page_controller, :index
endI thought this would give us everything, but it doesn't because of our LoadConcern plug. Either way, it might still be more flexible. I'm still inclined to punt on this for the time being.