- **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
This commit is contained in:
@@ -25,7 +25,7 @@ CI warns (but does not fail) when coverage drops below 80%.
|
||||
|
||||
## Architecture
|
||||
|
||||
The app is a minimal Go HTTP server that receives [DIUN](https://crazymax.dev/diun/) webhook events and exposes them via a JSON API and static HTML dashboard. All state is in-memory (no persistence).
|
||||
The app is a minimal Go HTTP server that receives [DIUN](https://crazymax.dev/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`)
|
||||
@@ -34,7 +34,7 @@ The app is a minimal Go HTTP server that receives [DIUN](https://crazymax.dev/di
|
||||
- `static/` — served verbatim at `/`
|
||||
|
||||
**Key data flow:**
|
||||
1. DIUN POSTs JSON to `/webhook` → `WebhookHandler` decodes into `DiunEvent` → stored in `updates[event.Image]` (latest event per image wins)
|
||||
2. Dashboard JS polls `GET /api/updates` → `UpdatesHandler` returns full map as JSON
|
||||
1. DIUN POSTs JSON to `/webhook` → `WebhookHandler` decodes into `DiunEvent` → stored in `updates[event.Image]` (the latest event per image wins)
|
||||
2. Dashboard JS polls `GET /api/updates` → `UpdatesHandler` 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()`.
|
||||
|
||||
Reference in New Issue
Block a user