Letterbox.Dev.Router (Letterbox v0.1.0-rc.0)

Copy Markdown View Source

The development page: write an email to the app and see what became of it, as Action Mailbox's conductor does. Mounted in the app's router, where only developers reach it:

import Letterbox.Dev.Router

if Application.compile_env(:my_app, :dev_routes) do
  scope "/dev" do
    pipe_through :browser
    letterbox_dev "/letterbox"
  end
end

At /dev/letterbox:

  • the messages, the newest first, with their status, refreshed while they change;
  • a form to write an email, with attachments, that is delivered as an ingress's would be (ingress: "dev"), routed and given to its mailbox;
  • each message as its mailbox got it (Letterbox.Message): its status and error, Retry and Delete, its text, its HTML in a frame that runs no script and loads nothing from elsewhere, its attachments and its raw email.

It is a page of its own, with its own style sheet and script, served under the mount: nothing to add to the app's assets. It is a library mounted with PhoenixMountable, so it takes PhoenixMountable's options (:as, :on_mount, …).

Summary

Functions

Mounts Letterbox.Dev.Router at path in a host router.

Functions

letterbox_dev(path, opts \\ [])

(macro)

Mounts Letterbox.Dev.Router at path in a host router.

import Letterbox.Dev.Router

scope "/" do
  pipe_through :browser
  letterbox_dev "/letterbox"
end

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