Support mixed routes
- Dominant language
- Elixir
- Stars
- 1.3k
- Forks
- 134
- PR merge metrics
- No merged PRs in 30d
Description
The [`beacon_site` macro](https://github.com/BeaconCMS/beacon/blob/544ca030a8ea804607bcff93dfba81e475165429/lib/beacon/router.ex#L80) injects the following catch-all route into the host app router:
```elixir
live "/*path", BeaconWeb.PageLive, :path
```
Which makes it hard to mix and match beacon pages with regular non-beacon pages from the host application. For example suppose one wants to have this route:
```elixir
live /:username, MyAppWeb.UsersLive
```
But at the same time serve beacon pages at the root as:
```elixir
beacon_site "/"
```
So if `beacon_site "/"` comes first it would match `mysite.com/username` and return 404 since there's no beacon page for the path `/username` or it would never match the beacon page `/about` if `live /:username` comes first.
------
A possible solution is letting Beacon manage all routes in the app, including the routes defined in the host app. Putting `beacon_site` at the top will match all request (catch-all) and if Beacon doesn't find a page then it forwards the request to the host app's Router.
Contributor guide
Research direction
Start with the beacon_site macro in lib/beacon/router.ex, especially the injected catch-all live route. Trace how Beacon handles a missing page and how the host application's router is reached. Done means beacon_site "/" can coexist with host routes such as /:username, with unmatched Beacon paths forwarded to the host router.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- elixir
- Domain
- backend, web-dev
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100