⚙️ JSONNET RUNE DIFFICULTY: Adept Behavioral

The Chain of Responsibility in Jsonnet

Passing requests along a chain of processing functions.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Chain of Responsibility
ARCANUM SCHOOL: Evocation // Cascading Spells
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// JSONNET PATTERN //
local HandleAuth(req, next) = if req.hasAuth then next(req) else { error: "No Auth" };
local HandleLog(req, next) = req + { logged: true } + next(req);
local HandleProcess(req) = { status: "processed", data: req.data };

local RequestPipeline(req) = 
  HandleAuth(req, function(r) HandleLog(r, function(r2) HandleProcess(r2)));

{
  result1: RequestPipeline({ hasAuth: true, data: "spell_data" }),
  result2: RequestPipeline({ hasAuth: false, data: "secret" })
}

Using higher-order functions, Jsonnet wires a pipeline of data processors, chaining logic until the payload is either refined into purity or rejected by a guardian.

Runic Tags: #behavioral #chain-of-responsibility #jsonnet