Imison.Web.Router (Imison v0.1.0)

Copy Markdown View Source

Mounts the dashboard in the host app's router.

Import this module in the host's router and call imison_dashboard/2 inside a scope that pipes through the host's :browser pipeline (session and CSRF):

import Imison.Web.Router

scope "/" do
  pipe_through :browser

  imison_dashboard "/errors"
end

The error list is at path, each error's detail page at <path>/errors/<id> and the notifications screen, where the email recipients and rules are set and a test email is sent, at <path>/notifications.

Every dashboard page asks for the login configured on the Imison instance (username and password): the login page at <path>/login signs in, and the Sign out button in the top bar posts to <path>/logout. The signed-in state lives in the host's session, so the :browser pipeline must fetch the session and protect from forgery, as a Phoenix app generated with mix phx.new does.

The dashboard serves its own stylesheet, fonts and script under the same path, so the host's asset pipeline is untouched. The host's endpoint needs the LiveView socket at /live, as a Phoenix app generated with LiveView has.

Options

  • :imison_name - the name of the Imison instance whose errors the dashboard shows. Defaults to Imison.
  • :as - the name of the route and of its live_session. Defaults to :imison_dashboard; mounting the dashboard twice in one router needs a different :as for each.

Summary

Functions

Defines the dashboard routes under path.

Functions

imison_dashboard(path, opts \\ [])

(macro)

Defines the dashboard routes under path.