StarView.Router (star_view v0.7.0)

Copy Markdown View Source

Explicit Phoenix routes for optional StarView pages and components.

import StarView.Router
scope "/", MyAppWeb do
  star_view "/counter", CounterPage
  star_view_components "/ds"
end

Events default to POST, preserving the existing controller dispatch boundary. Select additional CSRF-protected methods with :event_methods. Page GET events require get_events: true; component GET events require an explicit module list, such as get_events: [ReadOnlyComponent]. GET handlers must be read-only, and mutation handlers must still guard their intended method. Options and method/read-module lists must be literal keyword/list values; module attributes, variables and sigils are not evaluated as options.

Summary

Functions

Routes GET rendering, POST streaming, and POST /_event/:event by default.

Routes marked component/controller events under base, defaulting to POST.

Functions

star_view(path, page, opts \\ [])

(macro)

Routes GET rendering, POST streaming, and POST /_event/:event by default.

Options: event_methods: [:post, :put, :patch, :delete] selects unsafe event methods; get_events: true explicitly allows read-only GET events for this page. Aliased scopes expand the page module using Phoenix's normal semantics.

star_view_components(base \\ "/ds", opts \\ [])

(macro)

Routes marked component/controller events under base, defaulting to POST.

Additional unsafe methods use :event_methods. Read-only GET requires get_events: [Module, ...]: only those marked modules are dispatchable on the GET route. The list follows Phoenix scope aliases. A broad boolean GET opt-in is rejected so existing marked controllers retain their POST boundary.