Skip to main content

Module api

Module api 

Source
Expand description

The axum router, app state, the printer-source seam + fake source, and the HTTP API (reads + control).

Auth model: reads (/api/status, /api/ws) are always open; writes (control) are gated by an optional password (None = open). The token concept is gone — there’s nothing to put in a URL.

PrinterSource/Controller are the seams that keep the API testable without a real printer: tests and --fake use FakeSource/[FakeController]; live mode uses super::LiveSource/super::control::LiveController.

Structs§

AppState
Shared server state.
FakeSource
A fake source for --fake mode and tests, backed by a watch channel so it can stream like the real one. FakeSource::idle is static; FakeSource::ramping simulates a running print (temps climb toward target, progress advances) so the live charts have moving data to draw.

Traits§

PrinterSource
Something that can provide the printer’s current status and a live stream of updates. Abstracted so the server is testable without a network: tests and --fake mode use FakeSource, the live source (P2) wraps the MQTT monitor.

Functions§

router
Build the API router: open reads, password-gated writes, and — when the dashboard feature is on — the embedded SPA as the fallback.