Monitorex.MountOptions (monitorex v0.8.0)

Copy Markdown

Builds the LiveView session and socket assigns for the Monitorex dashboard.

The dashboard can be mounted under a path prefix (via a router scope or by mounting the endpoint behind a reverse proxy). The layout must build asset and navigation links from that prefix instead of hardcoding root-absolute paths. This module captures the request's mount prefix and the dashboard options into the LiveView session, and an on_mount hook copies them into the socket assigns so the root layout can read them.

session/2 is invoked by Monitorex.Router.http_dashboard/1 through the live_session :session option. on_mount/4 is registered as part of the default :on_mount hooks.

Summary

Functions

Returns the LiveView session map for the current request.

Functions

session(conn, assets_path, socket_path)

Returns the LiveView session map for the current request.

The session is populated with the dashboard mount prefix derived from conn.script_name (endpoint path mounts) plus the router scope segments in conn.path_info (minus the route-param segments), the configured assets path and the LiveSocket path.