Chime.Router (Chime v0.1.0-dev)

Copy Markdown View Source

Mounts Chime in the app's router.

import Chime.Router

scope "/api" do
  pipe_through :api_authenticated
  chime_api "/notifications"
end

# The links of the emails: no session, no CSRF token, as a mail
# client posts the one to unsubscribe (RFC 8058).
pipeline :mail do
  plug :accepts, ["html"]
end

scope "/" do
  pipe_through :mail
  chime_mail "/notifications/mail"
end

chime_api/2 mounts the feed and the preferences as JSON, for a frontend that Phoenix does not render (see Chime.API and the Any frontend guide), and chime_mail/2 the addresses of the emails' links, to unsubscribe and to open a notification (see Chime.Router.Mail), at the config's :mail_url. Each is a library mounted with PhoenixMountable: ordinary routes in the app's router (mix phx.routes lists them), behind the app's own scopes and pipelines.

The LiveViews of the app need no mount: Chime.Live and Chime.Components go in them.

Summary

Functions

Mounts the admin at path: see Chime.Router.Admin.

Mounts Chime.Router at path in a host router.

Mounts the addresses of the emails' links at path, the config's :mail_url: see Chime.Router.Mail.

Functions

chime_admin(path, opts \\ [])

(macro)

Mounts the admin at path: see Chime.Router.Admin.

chime_api(path, opts \\ [])

(macro)

Mounts Chime.Router at path in a host router.

import Chime.Router

scope "/" do
  pipe_through :browser
  chime_api "/chime"
end

Options

Every mount also takes the options listed in PhoenixMountable, such as :as, :on_mount and :csp_nonce_assign_key.

chime_mail(path, opts \\ [])

(macro)

Mounts the addresses of the emails' links at path, the config's :mail_url: see Chime.Router.Mail.