AttachedDashboard.Web.Router (AttachedDashboard v0.1.0)

Copy Markdown View Source

Phoenix router for the AttachedDashboard.

Also provides the attached_dashboard/1,2 macro that host apps use to mount the dashboard at a chosen prefix.

Usage

# router.ex
import AttachedDashboard.Web.Router

scope "/" do
  pipe_through :browser
  attached_dashboard "/admin/files"
end

Options

  • :on_mounton_mount hooks added to the dashboard's live_session. Use this to enforce authentication from the host app.
  • :as — override the route helper name. Defaults to :attached_dashboard.
  • :csp_nonce_assign_key — CSP nonce key (atom or map with :img, :style, :script keys).
  • :backlink — path in the host app to return to from the dashboard sidebar (e.g. "/admin"). When set, the sidebar title becomes a link to this path. Use a full URL/path string; the target lives outside the dashboard's live_session, so navigation is a regular request (full page reload).

Summary

Functions

Mounts the AttachedDashboard at the given path in the host app's router.

Callback invoked by Plug on every request.

Callback required by Plug that initializes the router for serving web requests.

Functions

attached_dashboard(path, opts \\ [])

(macro)

Mounts the AttachedDashboard at the given path in the host app's router.

call(conn, opts)

Callback invoked by Plug on every request.

formatted_routes(_)

Callback implementation for Phoenix.VerifiedRoutes.formatted_routes/1.

init(opts)

Callback required by Plug that initializes the router for serving web requests.

verified_route?(_, split_path)

Callback implementation for Phoenix.VerifiedRoutes.verified_route?/2.