Caravela.Gen.LiveRoute (Caravela v0.11.0)

Copy Markdown View Source

Renders router snippets for a Caravela domain's generated frontend routes — one block per render mode:

  • :live entities get live routes under the :browser pipeline (today's LiveView + WebSocket path).
  • :rest entities get caravela_rest routes under the :browser pipeline, served via caravela_svelte's Inertia-style HTTP transport. The router macro is imported from CaravelaSvelte.Router; this snippet prints the lines the developer pastes, it doesn't require caravela_svelte to be compiled at generation time.

Caravela does not edit router.ex automatically — these snippets are printed by mix caravela.gen.live for the developer to paste into their app's composition root.

Routes mirror the generator's own path convention:

/library/books
/library/books/new
/library/books/:id
/library/books/:id/edit

When the domain declares version "v1", the scope prefix shifts to /v1/library/... and the web-module alias picks up the V1. segment, matching Caravela.Gen.LiveView's module layout.

Summary

Functions

Return the router snippet covering every entity's frontend mode.

Functions

render(domain)

Return the router snippet covering every entity's frontend mode.

When the domain mixes :live and :rest entities, both blocks are printed. When every entity shares the same mode, only that block is printed. A domain with no entities returns an empty string.