Skip to content

refactor(api): share JSON writer between formatJSON and writeError - #207

Open
lewtec-bot[bot] wants to merge 1 commit into
masterfrom
janitor/write-json-response
Open

lewtec-bot[bot] wants to merge 1 commit into
masterfrom
janitor/write-json-response

Conversation

@lewtec-bot

@lewtec-bot lewtec-bot Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Problem

formatJSON and writeError each set Content-Type: application/json and encode a map[string]string.

Evidence: api/index.go:324, api/index.go:510

Change

Extract writeJSON and call it from both. Same payloads. Non-200 still goes through WriteHeader.

Verified

  • go test -p 1 -count=1 ./...
  • gofmt -l on the touched files
  • catalog pass on api/index.go and api/format_test.go

Both set application/json and encode a map[string]string. Route them
through writeJSON so the encode path lives in one place.
@lewtec-bot
lewtec-bot Bot requested a review from lucasew August 31, 2026 18:40
@vercel

vercel Bot commented Aug 31, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
articleparser Error Error Aug 31, 2026 6:41pm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant