View Source Beacon.LiveAdmin.Router (Beacon LiveAdmin v0.1.0-rc.2)
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
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 ofon_mount
hooks passed tolive_session
. This will allow for authenticated routes, among other uses.
@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"
@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"
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 SourceGenerates 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"