Files
DiunDashboard/.claude/CLAUDE.md
Jean-Luc Makiola 1983a3bed9
Some checks failed
CI / build-test (push) Successful in 1m4s
CI / docker (push) Failing after 2s
- **fix(errors):** ensure proper error handling with errors.Is instead of direct comparison for http.ErrServerClosed
- **fix(sql):** wrap `rows.Close` in a `defer` function to safely handle potential close errors
- **fix(api):** handle JSON encoding errors in API responses to prevent unhandled edge cases
- **docs:** correct typos and improve phrasing in `.claude/CLAUDE.md`
- **test:** add error handling for `UpdateEvent` in test cases
2026-02-25 20:44:18 +01:00

1.6 KiB

CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

Commands

# Run all tests with coverage
go test -v -coverprofile=coverage.out -coverpkg=./... ./...

# Run a single test
go test -v -run TestWebhookHandler ./test/diunwebhook/

# Run the app locally
go run ./cmd/diunwebhook/

# Build Docker image
docker build -t diun-webhook-dashboard .

# Run with Docker Compose
docker compose up -d

CI warns (but does not fail) when coverage drops below 80%.

Architecture

The app is a minimal Go HTTP server that receives DIUN webhook events and exposes them via a JSON API and static HTML dashboard. All states are in-memory (no persistence).

Package layout:

  • pkg/diunwebhook/ — core library: DiunEvent struct, in-memory updates map (guarded by sync.Mutex), and HTTP handlers (WebhookHandler, UpdatesHandler)
  • cmd/diunwebhook/main.go — wires the handlers and static file server onto net/http's default mux, listens on :8080
  • test/diunwebhook/ — external test package (package diunwebhook_test) that imports pkg/diunwebhook; uses httptest for handler tests
  • static/ — served verbatim at /

Key data flow:

  1. DIUN POSTs JSON to /webhookWebhookHandler decodes into DiunEvent → stored in updates[event.Image] (the latest event per image wins)
  2. Dashboard JS polls GET /api/updatesUpdatesHandler returns a full map as JSON

Test helpers exposed from the library package (not part of the public API, only for tests): GetUpdatesMap(), UpdatesReset(), UpdateEvent().