ExBoxPacker.PackerPreview (ExBoxPacker v0.2.0)

Copy Markdown View Source

A forward-able Plug that renders a 3D preview of packings captured via ExBoxPacker.Preview.

Mount it under a dev-only scope, and mount it outside any protect_from_forgery (CSRF) pipeline — the tool serves its own JavaScript assets and a JSON POST /api/pack endpoint, both of which Plug.CSRFProtection blocks. A scope with no :browser pipeline is ideal (this mirrors how Swoosh's mailbox and Phoenix's GraphiQL dev tools are mounted):

scope "/dev" do
  forward "/box-packer", ExBoxPacker.PackerPreview
end

If you must mount it inside a :browser/CSRF pipeline, the JavaScript assets still load (the Plug opts them out of CSRF's cross-origin-script guard), but POST /api/pack will be rejected unless the request carries a valid CSRF token for the endpoint's host.

Requires the optional :plug dependency and a running ExBoxPacker.Preview.Collector.

Summary

Functions

Callback implementation for Plug.call/2.

Callback implementation for Plug.init/1.

Functions

call(conn, opts)

Callback implementation for Plug.call/2.

init(opts)

Callback implementation for Plug.init/1.