Route macros a host app mounts to get the server's HTTP surface.
A host owns its own router; this module supplies the routes rather than imposing a router, so you choose which surfaces exist. Import it, declare the pipelines, then call the groups you want:
defmodule MyGame.Router do
use Phoenix.Router
import GamendWeb.Router.Shared
gamend_pipelines()
gamend_api_routes()
gamend_public_api_routes()
gamend_authenticated_live_routes()
gamend_admin_live_routes(GamendWeb.Router.Shared.require_admin_on_mount())
endLeaving a group out removes those endpoints entirely — that is the supported way to ship a smaller surface, rather than deleting files from the dependency.
Groups
| Macro | Mounts |
|---|---|
gamend_pipelines/0 | The :browser, :api, :api_auth and :api_admin pipelines the rest expect. Call it first. |
gamend_api_routes/0 | Auth, current user, lobbies, chat, KV, groups, parties, friends, notifications, quests, tournaments, matchmaking - the whole player-facing API. |
gamend_public_api_routes/0 | Unauthenticated listings, each behind its own LIST_*_ENABLED flag. |
gamend_api_auth_routes/0, gamend_oauth_routes/0 | Login, registration and the OAuth provider flows. |
gamend_api_docs_routes/0 | The OpenAPI spec and Swagger UI at /api/docs. |
gamend_authenticated_live_routes/0 | Player-facing LiveViews (lobbies, chat, quests, settings). |
gamend_admin_live_routes/1 | The /admin console. Takes the on_mount hook from require_admin_on_mount/0. |
gamend_admin_api_routes/0 | Admin HTTP mirrors of every console action. |
gamend_static_page_routes/0, gamend_support_routes/0 | Host pages and support endpoints. |
gamend_configured_page_fallback_routes/0 | Catch-all for theme-configured pages. Mount last. |
The narrower macros (gamend_chat_api_routes/0,
gamend_quest_api_routes/0 and so on) are the pieces the aggregate
macros above are built from; call them directly when you want one subsystem
without its neighbours.
Summary
Functions
Core's admin LiveView routes, optionally extended with host-specific ones.
Every core API route. :chat_update swaps the controller behind
PATCH /api/v1/chat/messages/:id for a host that moderates its own edits.
Core's authenticated LiveView routes, extendable the same way as the admin ones.
Core's public LiveView routes, extendable with host-specific ones via :do.
Core's static pages. :home swaps the controller behind / for a host's own
(action :home); overriding by declaring the route first would compile to an
unreachable clause.
Functions
Core's admin LiveView routes, optionally extended with host-specific ones.
The do block is spliced into the same live_session, so host routes get the
admin pipeline and on_mount chain without the host restating them:
gamend_admin_live_routes @require_admin_on_mount do
live "/admin/my_thing", MyThingLive, :index
endIt exists so a host that needs one extra admin page does not fork the whole list to get it. A fork looks harmless and then silently rots — every core admin page added afterwards is missing from that host, with no error, just a 404 nobody connects to the change that caused it.
Every core API route. :chat_update swaps the controller behind
PATCH /api/v1/chat/messages/:id for a host that moderates its own edits.
Core's authenticated LiveView routes, extendable the same way as the admin ones.
:do splices host routes into the same live_session; :chat swaps the chat
LiveView for a host's own. The session name is fixed, so a host cannot declare
a second live_session :require_authenticated_user of its own — it extends
this one or forks the lot.
Core's public LiveView routes, extendable with host-specific ones via :do.
Same reasoning as the admin and authenticated variants: live_session :current_user can only be declared once, so a host adding one public page
extends this rather than restating core's list.
Core's static pages. :home swaps the controller behind / for a host's own
(action :home); overriding by declaring the route first would compile to an
unreachable clause.