Skip to content

Determine how to best handle root routing for a concern #79

@dsnider

Description

@dsnider

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
end

I 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions