View Source Phoenix.LiveDashboard.Router (LiveDashboard v0.7.0)
Provides LiveView routing for LiveDashboard.
Link to this section Summary
Functions
Defines a LiveDashboard route.
Link to this section Functions
Defines a LiveDashboard route.
It expects the path
the dashboard will be mounted at
and a set of options.
This will also generate a named helper called live_dashboard_path/2
which you can use to link directly to the dashboard, such as:
<%= link "Dashboard", to: live_dashboard_path(conn, :home) %>
Note you should only use link/2
to link to the dashboard (and not
live_redirect/live_link
, as it has to set its own session on first
render.
options
Options
:live_socket_path
- Configures the socket path. it must match thesocket "/live", Phoenix.LiveView.Socket
in your endpoint.:csp_nonce_assign_key
- an assign key to find the CSP nonce value used for assets. Supports eitheratom()
or a map of type%{optional(:img) => atom(), optional(:script) => atom(), optional(:style) => atom()}
:ecto_repos
- the repositories to show database information. Currently only PSQL databases are supported. If you don't specify but your app is running Ecto, we will try to auto-discover the available repositories. You can disable this behavior by setting[]
to this option.:env_keys
- Configures environment variables to display. It is defined as a list of string keys. If not set, the environment information will not be displayed:home_app
- A tuple with the app name and version to show on the home page. Defaults to{"Dashboard", :phoenix_live_dashboard}
:metrics
- Configures the module to retrieve metrics from. It can be amodule
or a{module, function}
. If nothing is given, the metrics functionality will be disabled. Iffalse
is passed, then the menu item won't be visible.:metrics_history
- Configures a callback for retrieving metric history. It must be an "MFA" tuple of{Module, :function, arguments}
such as metrics_history: {MyStorage, :metrics_history, []} If not set, metrics will start out empty/blank and only display data that occurs while the browser page is open.:request_logger
- By default the Request Logger page is enabled. Passingfalse
will disable this page.:request_logger_cookie_domain
- Configures the domain the request_logger cookie will be written to. It can be a string or:parent
atom. When a string is given, it will directly set cookie domain to the given value. When:parent
is given, it will take the parent domain from current endpoint host (if host is "www.acme.com" the cookie will be scoped on "acme.com"). When not set, the cookie will be scoped to current domain.:allow_destructive_actions
- When true, allow destructive actions directly from the UI. Defaults tofalse
. The following destructive actions are available in the dashboard:- "Kill process" - a "Kill process" button on the process modal
Note that custom pages given to "Additional pages" may support their own destructive actions.
:additional_pages
- A keyword list of additional pages
examples
Examples
defmodule MyAppWeb.Router do
use Phoenix.Router
import Phoenix.LiveDashboard.Router
scope "/", MyAppWeb do
pipe_through [:browser]
live_dashboard "/dashboard",
metrics: {MyAppWeb.Telemetry, :metrics},
env_keys: ["APP_USER", "VERSION"],
metrics_history: {MyStorage, :metrics_history, []},
request_logger_cookie_domain: ".acme.com"
end
end