Skip to main content

Module api

Module api 

Source
Expand description

The HTTP surface, built by folding over the declared operations.

§The router is the declaration

Nothing here writes a route out. router walks OPERATIONS and registers one route per entry beneath the one versioned prefix, so the set served and the set declared cannot come apart — and the ten mutating operations share one handler which is given the ActionKind its own entry declares, so a request cannot reach an action the operation it was sent to does not name.

§Every action takes the same one path

An action asked for here goes to Supervisor::request_action, which is the same call an operator’s action makes and an agent’s action makes. The policy is not re-implemented here and is not bypassed here: a rejected request answers the rejection the policy made, carrying its reason, the value asked for and the range allowed, and reaches no action method of the printer port at all.

§Nothing is served to a caller that did not present the credential

Every route beneath the versioned prefix — and the prefix’s own fallback, so that a path nothing serves is refused the same way — sits behind authenticate, which runs before any extractor reads a path, a query or a body. A request whose Authorization header is not exactly Bearer <the credential in force> is answered 401 there, so it reaches no handler, no store, no printer port and no record. There is no route that skips it and no configuration that turns it off: ApiState cannot be built without the credential it is checked against.

Structs§

ApiState
What every handler is given: the supervisor, and the stores the reads answer out of — the four aggregates a route reads, and not the actions, which reach the store through the supervisor alone.
HistoryParams
How many events a history read asks for, when it asks for a number.

Constants§

BODY_BOUND
How much of a request’s body this server reads, admitted or refused.
DRAIN_BOUND
How long authenticate waits for a refused request’s body to arrive.

Functions§

authenticate
Admit a request that presented the credential in force, and refuse every other before anything reads it.
router
Every public operation, beneath the one versioned prefix.