Follow-up to the #662 review, sequenced AFTER #662 lands (touching Handle now would conflict with the contributor's rework).
Problem: cross-cutting request guards are scattered — the Turnstile check is an inline block in Handle before method dispatch, the per-IP rate limiter lives inside the per-method handlers. Two guards in two ad-hoc places already produced an ordering bug (Turnstile before rate limiting — #662 review, being fixed there); every future guard would add another scattered if.
Proposal: an ordered guard chain in internal/rpchandler — type guard func(c fiber.Ctx, body *rpcRequest) error, evaluated before dispatch: rate limit → Turnstile (when enabled) → dispatch. Fiber middleware is deliberately NOT the vehicle: there is a single RPC endpoint and the Turnstile token lives in the JSON body, so app-level middleware would have to buffer and double-parse the body.
Benefit: ordering becomes explicit and testable (a unit test can assert the chain order — exactly the class of bug the #662 review caught), and future guards (audit logging, honeypot fields, IP allowlists, additional bot checks) become one list entry with a defined position.
Assisted by claude-code:claude-fable-5 — Session
Follow-up to the #662 review, sequenced AFTER #662 lands (touching
Handlenow would conflict with the contributor's rework).Problem: cross-cutting request guards are scattered — the Turnstile check is an inline block in
Handlebefore method dispatch, the per-IP rate limiter lives inside the per-method handlers. Two guards in two ad-hoc places already produced an ordering bug (Turnstile before rate limiting — #662 review, being fixed there); every future guard would add another scatteredif.Proposal: an ordered guard chain in
internal/rpchandler—type guard func(c fiber.Ctx, body *rpcRequest) error, evaluated before dispatch: rate limit → Turnstile (when enabled) → dispatch. Fiber middleware is deliberately NOT the vehicle: there is a single RPC endpoint and the Turnstile token lives in the JSON body, so app-level middleware would have to buffer and double-parse the body.Benefit: ordering becomes explicit and testable (a unit test can assert the chain order — exactly the class of bug the #662 review caught), and future guards (audit logging, honeypot fields, IP allowlists, additional bot checks) become one list entry with a defined position.
Assisted by claude-code:claude-fable-5 — Session