Fiber HTTP handlers: API struct, route registration, auth surface, user job endpoints, error rendering.
APIstruct +Registerwires routes. Handlers are thin — auth primitives, user job operations, API key management, errors live in separate files.- Central
handler.RenderError(wired incmd/serverviafiber.Config{ErrorHandler: handler.RenderError}) renders JSON envelope:*fiber.Error→its code,pgx.ErrNoRows→404, FK-violation (SQLSTATE 23503)→404, everything else→500. - Handlers signal failure by returning an error —
fiber.NewError(status, msg)for specific codes, bare error (e.g.pgx.ErrNoRows) for common cases. Don't hand-roll per-handler error JSON; don't re-mapErrNoRowsin read handlers (justreturn err).
register/loginset JWT cookie + return{"data": user}.logoutclears it.meis guarded byRequireAuthmiddleware.- Rate-limited credential endpoints (10/min, keyed on client IP).
view/apply/save/trackinteraction endpoints. Addressed by job's public:slug(resolved to internal id before write). All writes are idempotent upserts behindRequireAuthOrKey.- Return
{"data": interaction}withuser_idomitted; public job reads stay unauthenticated.
- Genuinely domain-specific status choices (e.g.
Mereturning 401 for a gone user token) stay in the handler. - Recovered panic is not double-reported (recover middleware marks it via
handler.LocalPanicReported). - Sentry reports only fall-through unexpected 500s — routine errors never reported.