View Source AshAdmin.Router (ash_admin v0.11.3)

Provides LiveView routing for AshAdmin.

Summary

Functions

Can be used to create a :browser pipeline easily if you don't have one.

Defines an AshAdmin route. It expects the path the admin dashboard will be mounted at and a set of options.

Functions

Link to this macro

admin_browser_pipeline(name \\ :browser)

View Source (macro)

Can be used to create a :browser pipeline easily if you don't have one.

By default it is called :browser, but you can rename it by supplying an argument, for example:

defmodule MyAppWeb.Router do
  use Phoenix.Router

  import AshAdmin.Router
  admin_browser_pipeline :something

  scope "/" do

    pipe_through [:something]
    ash_admin "/admin"
  end
end
Link to this macro

ash_admin(path, opts \\ [])

View Source (macro)

Defines an AshAdmin route. It expects the path the admin dashboard will be mounted at and a set of options.

Options

  • :live_socket_path - Optional override for the socket path. it must match the socket "/live", Phoenix.LiveView.Socket in your endpoint. Defaults to /live.

  • :on_mount - Optional list of hooks to attach to the mount lifecycle.

  • :session - Optional extra session map or MFA tuple to be merged with the session.

  • :csp_nonce_assign_key - Optional assign key to find the CSP nonce value used for assets Supports either atom() or %{optional(:img) => atom(), optional(:script) => atom(), optional(:style) => atom()}
    Defaults to ash_admin-Ed55GFnX for backwards compatibility.

  • :live_session_name - Optional atom to name the live_session. Defaults to :ash_admin.

Examples

defmodule MyAppWeb.Router do
  use Phoenix.Router

  scope "/" do
    import AshAdmin.Router

    # Make sure you are piping through the browser pipeline
    # If you don't have one, see `admin_browser_pipeline/1`
    pipe_through [:browser]

    ash_admin "/admin"
    ash_admin "/csp/admin", live_session_name: :ash_admin_csp, csp_nonce_assign_key: :csp_nonce_value
  end
end