Take a module route's copies and printer in its JSON body

API inputs go in the JSON body, never in query parameters (owner,
2026-12-01; design.md, "Inputs go in the JSON body"). The module routes
took copies and printer in the query, beside a body that was the
module's payload alone.

The body of POST /api/v1/print/{module} and /api/v1/preview/{module}
now holds the payload under payload, with copies and printer beside it:
{"payload": {...}, "copies": 2, "printer": "default"}. A module may name
its payload's fields as it likes, since none can collide with copies or
printer; that matters for ntfy's messages and for any module that takes
another system's JSON. The body is decoded strictly, and its problems
are answered at once as invalid_payload, each named by its path in the
body: copies, or, once the body is right, payload.done[0] for one the
module finds. A field named body is quoted, "body", so it is never
taken for a problem with the whole body. copies takes 0-5, as a job's
does, 0 meaning one. A query string on these routes gets 400
invalid_query, now worded "query parameters are not accepted".

The ntfy client recipes in docs/api.md wrap $NTFY_RAW in the body. The
Windows command was run here through cmd.exe and PowerShell, and the
printf of the Linux one in sh, each with a message holding quotes, & and
%; neither ran under an ntfy client. No tag carries the module query, so
the 0.2.0 entries in the CHANGELOG change in place (owner, 2026-12-01).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
57_WolveandClaude Opus 5.5 committed 2026-12-01 22:29:02 -06:00
1 parent cbac0b5f03
commit 9e829bfce7
16 files changed
+336 -217

No files matched your search

+5 -4
View File
@@ -319,8 +319,9 @@ upgrade a 0.1 install.
`?`.
- Modules, which build a receipt from a few plain fields:
- `POST /api/v1/print/:module` queues it and `POST /api/v1/preview/:module`
previews it. `?copies=` sets the copies; `?printer=` is reserved and
takes only `default`.
previews it. The body holds the module's payload under `payload`, with
`copies` beside it and `printer`, which is reserved and takes only
`default`: `{"payload": {...}, "copies": 2}`.
- `GET /api/v1/modules` lists the modules.
- `uberbringer preview --module <name>` shows the receipt a module builds
from a payload.
@@ -329,8 +330,8 @@ upgrade a 0.1 install.
`{"title", "text", "items", "done"}`, with `style`, `footer` and `stamp`
as options. `docs/api.md` § Modules describes it.
- The module routes answer with the error codes `invalid_payload` (400),
`invalid_query` (400), `unknown_printer` (400), `module_not_found` (404)
and `module_failed` (422).
`invalid_query` (400) for a query string, `unknown_printer` (400),
`module_not_found` (404) and `module_failed` (422).
- `[format]` with `max_lines` (default 2000): a job that would print more
lines fails instead of printing. `/api/v1/preview` answers such a job with
`422` and the code `too_many_lines`.