Marker-based Datastar dispatch for Phoenix controllers.
A controller is dispatchable when it uses use StarView, which
injects __star_view_handler__/0.
What this plug does
- Fetches object-only signals from JSON body or the Datastar query parameter.
- Starts the SSE response (
StarView.start/1). - Calls
handle_event/3on the target controller. - Lets
signal/3patch browser signals immediately as your handler runs.
This means your handle_event/3 callbacks never need to call StarView.start/1
or manually send signal patches -- just use signal/3 and patch_element/3.
Malformed signals return HTTP 400 and oversized signals return 413 before SSE
or the handler starts. A typed StarView.SSE.TransportError with reason
:closed, :econnreset, or :epipe halts normally; other exceptions are
logged and re-raised. Route
authentication and per-event authorization remain the application's job.
An optional :only module list narrows marker dispatch for a route. It never
bypasses the marker requirement. The default preserves legacy dispatch; the
new router macros use this list for explicit read-only GET component routes.