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:
1 parent
cbac0b5f03
commit
9e829bfce7
16 files changed
+336
-217
No files matched your search
+19
-15
@@ -338,25 +338,29 @@ client ─HTTPS─▶ Caddy ─▶ server ── validate ──▶ printqueue (
|
||||
field of the wrong type would otherwise also be reported as missing.
|
||||
- A module checks its payload for everything the blocks would refuse, and
|
||||
words the problems in the payload's terms (`done[0]: index 5 is out of
|
||||
range`). A built job that still fails validation is a bug in the module:
|
||||
the client gets `422` `module_failed` with the problems, and it is
|
||||
logged and reported to Sentry once, without the problems, which can
|
||||
quote the payload.
|
||||
range`). The module routes name each by its path in the request body
|
||||
(`payload.done[0]`). A built job that still fails validation is a bug
|
||||
in the module: the client gets `422` `module_failed` with the problems,
|
||||
and it is logged and reported to Sentry once, without the problems,
|
||||
which can quote the payload.
|
||||
- Labels are in English, and the footer's time zone and date format come
|
||||
from the config (owner, 2026-11-29).
|
||||
- A module never reads the clock. It gets the time, zone and layout in an
|
||||
`Env`, from `format.timezone` and `format.time_layout`, so its output is
|
||||
reproducible in tests. The binary embeds the zone database, because
|
||||
Windows and slim containers have none.
|
||||
- Module routes take `copies` and the reserved `printer` (only `default`
|
||||
until a second printer is configured) in the query. Any other parameter
|
||||
is refused, for the same reason unknown config keys are: a typo must
|
||||
not be ignored.
|
||||
- A module route's body holds the payload under `payload`, with `copies`
|
||||
and the reserved `printer` (only `default` until a second printer is
|
||||
configured) beside it:
|
||||
`{"payload": {...}, "copies": 2, "printer": "default"}`. No name a
|
||||
module gives its payload's fields can collide with them. The body is
|
||||
decoded strictly, so any other field is refused, for the same reason
|
||||
unknown config keys are: a typo must not be ignored.
|
||||
- The registry lists modules sorted by name.
|
||||
- The module routes are entries in the route table like any other. The
|
||||
OpenAPI document describes their body as a JSON object whose fields the
|
||||
module defines, not as a strict schema: one route serves every module,
|
||||
and each module checks its own payload.
|
||||
OpenAPI document describes the payload as a JSON object whose fields
|
||||
the module defines, not as a strict schema: one route serves every
|
||||
module, and each module checks its own payload.
|
||||
- **Notifications print as one card.** The `notify` and `ntfy` modules turn
|
||||
their payloads into a `Notice` and lay it out with the same `Card`, which
|
||||
the ntfy subscriptions use too.
|
||||
@@ -502,10 +506,10 @@ client ─HTTPS─▶ Caddy ─▶ server ── validate ──▶ printqueue (
|
||||
the request's JSON body, never in a query parameter. The path holds only
|
||||
a resource's ID, or a fixed word that names the route, as `last`,
|
||||
`failed` and `uncertain` do in `/jobs/.../reprint`. A `GET` takes no
|
||||
inputs beyond its path. Some of the API breaks the rule today, and a
|
||||
later change makes it follow:
|
||||
- the module routes' `copies` and `printer` query parameters, and the
|
||||
`invalid_query` error code that refuses them;
|
||||
inputs beyond its path. The module routes follow it: their body holds
|
||||
the module's payload, `copies` and `printer`, and a query string gets
|
||||
`400` `invalid_query`. Some of the plans break the rule today, and a
|
||||
later change makes them follow:
|
||||
- the `?printer=` that docs/plans/printers.md puts on `/print`,
|
||||
`/preview` and the module routes;
|
||||
- the filters and paging that docs/plans/job-store.md's phase 2 puts in
|
||||
|
||||
Reference in new issue
Block a user