BeamConsole.Router (beam_console v0.5.2)

Copy Markdown View Source

Router helpers for mounting BeamConsole inside a Phoenix application.

The host owns authentication, authorization, endpoint configuration, and deployment exposure.

Summary

Functions

Builds validated LiveView session and route options for the router macro.

Builds the serializable session metadata used by the embedded LiveView.

Merges a host-supplied session map with BeamConsole's reserved mount metadata.

Imports the beam_console/1 and beam_console/2 router macros.

Mounts the BeamConsole LiveView and its self-contained assets.

Functions

__options__(prefix, options)

@spec __options__(
  String.t(),
  keyword()
) :: {atom(), keyword(), keyword()}

Builds validated LiveView session and route options for the router macro.

__session__(conn, prefix, live_path, live_transport)

@spec __session__(Plug.Conn.t() | map(), String.t(), String.t(), String.t()) :: map()

Builds the serializable session metadata used by the embedded LiveView.

__session__(conn, prefix, live_path, live_transport, host_session)

@spec __session__(
  Plug.Conn.t() | map(),
  String.t(),
  String.t(),
  String.t(),
  map() | tuple() | nil
) :: map()

Merges a host-supplied session map with BeamConsole's reserved mount metadata.

__using__(options)

(macro)

Imports the beam_console/1 and beam_console/2 router macros.

beam_console(path, options \\ [])

(macro)

Mounts the BeamConsole LiveView and its self-contained assets.

The macro belongs inside a Phoenix router. The host application is responsible for placing the route behind an appropriate browser pipeline and any required authentication or authorization.

Options

  • :enabled - mounts the routes when true; defaults to true only in the :dev Mix environment
  • :as - names the LiveView session and route helpers; defaults to :beam_console and must be distinct for multiple mounts
  • :on_mount - host authorization hooks run before BeamConsole's hook; defaults to []
  • :session - a string-keyed map or {module, function, arguments} callback merged into the LiveView session; defaults to nil
  • :socket_path - the host LiveView socket path; defaults to "/live" and must match the socket configured by the endpoint
  • :transport - "websocket" or "longpoll"; defaults to "websocket" and must match a transport enabled by the endpoint