Cybersecurity-Projects/PROJECTS/beginner/canary-token-generator/backend/internal/token
CarterPerez-dev 593433fc03 feat(canary): manage page handlers + DTOs (GET + DELETE /m/{manage_id})
Adds the HTTP layer for spec §8.4. The UUID in the URL is the
capability — no other auth required, by design.

- token/dto.go: ManageTokenView (slimmer than Response — no manage_id,
  no manage_url, no metadata, since the user is already on the manage
  page and those would be redundant), ManagePage{NextCursor, HasMore},
  ManageResponse{Token, Events, EventsTotal, EventsSilencedActive, Page}.
  Token.ToManageView(triggerURL) builder. Events use the existing
  event.Response (already matches spec shape exactly).
- token/handler.go: EventQuery + DedupCounter interfaces declared near
  the existing EventRecorder + FingerprintRecorder; same dependency-
  injection style. NewHandler signature gains the two new args (5 → 6;
  test sites + main.go updated).
- GetManage(w, r): parses ?cursor= (int64, must be >= 0) and ?limit=
  (defaults 20, capped at 100). Returns 404 envelope for unknown
  manage_id (envelope, not bare http.NotFound, so frontend gets a
  parseable error code). 400 BAD_CURSOR for non-numeric or negative.
  Calls svc.GetByManageID + eventQuery.ListByToken + CountByToken +
  dedupCounter.CountActiveDedup; assembles the manage payload.
- DeleteManage(w, r): 204 on success, 404 on miss. Cascade-delete is
  via the existing tokens-events FK ON DELETE CASCADE.
- buildPage helper: NextCursor is the string of the last event's ID
  iff len(events) == limit (matches spec example "next_cursor": "41").

Tests cover happy path, 404 on unknown id, 400 on bad/negative cursor,
?limit= respected, ?limit=999 capped at 100, DELETE happy + 404.
2026-05-14 01:07:09 -04:00
..
generators refactor(canary): consolidate realIP into middleware across 5 generators 2026-05-14 00:31:49 -04:00
contract.go feat(canary): event + notify domain — contracts, senders, services 2026-05-14 00:30:42 -04:00
dto.go feat(canary): manage page handlers + DTOs (GET + DELETE /m/{manage_id}) 2026-05-14 01:07:09 -04:00
entity.go feat(canary): Phase 1 — Postgres schema + token & event repositories 2026-05-10 05:47:24 -04:00
handler.go feat(canary): manage page handlers + DTOs (GET + DELETE /m/{manage_id}) 2026-05-14 01:07:09 -04:00
handler_test.go feat(canary): manage page handlers + DTOs (GET + DELETE /m/{manage_id}) 2026-05-14 01:07:09 -04:00
repository.go fix(canary): clear pre-audit lint debt + migrate golangci config to v2 2026-05-12 02:49:56 -04:00
repository_test.go fix(canary-phase1): clear all post-phase-1 audit observations + header normalization 2026-05-10 06:15:26 -04:00
service.go feat(canary): event.CountActiveDedup + token.DeleteByManageID for manage page 2026-05-14 01:06:45 -04:00
service_test.go feat(canary): event.CountActiveDedup + token.DeleteByManageID for manage page 2026-05-14 01:06:45 -04:00
types.go feat(canary): token HTTP handlers (API + trigger routes) 2026-05-13 15:16:41 -04:00