Skip to content

Add host constraints to mix phx.routes output#6594

Open
t3chw wants to merge 1 commit intophoenixframework:mainfrom
t3chw:add-host-constraints-to-phx-routes
Open

Add host constraints to mix phx.routes output#6594
t3chw wants to merge 1 commit intophoenixframework:mainfrom
t3chw:add-host-constraints-to-phx-routes

Conversation

@t3chw
Copy link

@t3chw t3chw commented Feb 8, 2026

Fixes #6589

This adds host constraints to the mix phx.routes output.

Routes defined inside scope blocks with a host: option are now prefixed
with the corresponding host, making it easier to distinguish routes that share
the same path but differ by host.

Example:

Before:
GET /users MyAppWeb.UserController :index
GET /users MyAppWeb.AdminUserController :index

After:
[api.example.com] GET /users MyAppWeb.UserController :index
[admin.example.com] GET /users MyAppWeb.AdminUserController :index

@SteffenDE SteffenDE requested a review from josevalim February 21, 2026 15:52
Map.put(route, :label, nested_route.label)
route
|> Map.put(:label, nested_route.label)
|> Map.put(:hosts, Map.get(nested_route, :hosts, route.hosts))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need a test for this part of the code.

In particular, if both the parent and the child router define a host, what would happen? We would probably check the host in both cases, so it is not like one would win over the other?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add host constraints to mix phx.routes output

3 participants