View Source Beacon.LiveAdmin.Router (Beacon LiveAdmin v0.1.1)

Routing for Beacon LiveAdmin.

Summary

Functions

Mount Beacon LiveAdmin routes to manage running sites in the cluster.

Generates the root path with the admin prefix.

Generates a path with the proper admin prefix for a site.

Generate the path to serve files in priv/static.

Generates a url with the proper admin prefix for a site.

Types

@type conn_or_socket() :: Phoenix.LiveView.Socket.t() | Plug.Conn.t()

Functions

Link to this macro

beacon_live_admin(prefix, opts \\ [])

View Source (macro)

Mount Beacon LiveAdmin routes to manage running sites in the cluster.

Examples

defmodule MyAppWeb.Router do
  use Phoenix.Router
  use Beacon.LiveAdmin.Router

  scope "/", MyAppWeb do
    pipe_through :browser
    beacon_live_admin "/admin", on_mount: [SomeHook]
  end
end

Options

  • :on_mount (optional) , an optional list of on_mount hooks passed to live_session. This will allow for authenticated routes, among other uses.
Link to this function

beacon_live_admin_path(conn_or_socket)

View Source
@spec beacon_live_admin_path(conn_or_socket()) :: String.t()

Generates the root path with the admin prefix.

Example

iex> Beacon.LiveAdmin.Router.beacon_live_admin_path(@socket)
"/my_admin"
Link to this function

beacon_live_admin_path(conn_or_socket, site, path, params \\ %{})

View Source
@spec beacon_live_admin_path(
  conn_or_socket(),
  Beacon.Types.Site.t(),
  String.t() | atom(),
  map() | keyword()
) :: String.t()

Generates a path with the proper admin prefix for a site.

Examples

iex> Beacon.LiveAdmin.Router.beacon_live_admin_path(@socket, :my_site, "/pages")
"/my_admin/my_site/pages"

iex> Beacon.LiveAdmin.Router.beacon_live_admin_path(@socket, :my_site, "/pages", status: :draft)
"/my_admin/my_site/pages?status=draft"
Link to this function

beacon_live_admin_static_path(file)

View Source

Generate the path to serve files in priv/static.

See the actual configuration in Beacon.LiveAdmin.Plug.

Example

iex> Beacon.LiveAdmin.Router.beacon_live_admin_static_path("/images/logo.webp")
"__beacon_live_admin_static__/images/logo.webp"
Link to this function

beacon_live_admin_url(endpoint, conn_or_socket, site, path, params \\ %{})

View Source

Generates a url with the proper admin prefix for a site.

Example

iex> Beacon.LiveAdmin.Router.beacon_live_admin_url(MyAppWeb.Endpoint, @socket, :my_site, "/pages")
"https://myapp.com/my_admin/my_site/pages"