PhoenixFlags.Router (PhoenixFlags v0.10.0)

Copy Markdown View Source

Provides a router macro for mounting the PhoenixFlags dashboard.

Usage

defmodule MyAppWeb.Router do
  use Phoenix.Router
  import PhoenixFlags.Router

  scope "/admin" do
    pipe_through [:browser, :require_admin]

    flags_dashboard "/flags",
      config: MyApp.SystemConfig
  end
end

Options

  • :config (required) — the module that use PhoenixFlags

  • :on_mount — list of Phoenix.LiveView.on_mount/1 hooks to add to the live session (e.g. for authentication)

  • :live_socket_path — defaults to "/live"

  • :app_js — path to the host application's JS bundle, which must connect a LiveSocket. Defaults to "/assets/js/app.js".

  • :favicon — href for the dashboard's icon. Defaults to "data:,", an empty document, which stops the browser asking: a layout with no icon makes it request /favicon.ico, and a host that does not serve one gets a 404 in the console of an otherwise working page. Point it at your own to show it instead.

  • :app_js_type — the script tag's type. Pass "module" when the host bundle is ESM, which esbuild emits with --format=esm and which any bundle using import() for code splitting needs. Omitted by default, so a classic bundle is loaded as it always was.

    Getting this wrong is quiet and total: an ESM bundle loaded as a classic script throws import declarations may only appear at top level of a module before it defines anything, so the LiveSocket never connects and every control on the dashboard does nothing at all.

Summary

Functions

Defines routes for the PhoenixFlags dashboard.

Functions

flags_dashboard(path, opts)

(macro)

Defines routes for the PhoenixFlags dashboard.