Conversation
The private writeJSONResponse function in http_helpers.go was a pure passthrough to httputil.WriteJSONResponse with no added behaviour. Remove it and update the 4 callers to use httputil.WriteJSONResponse directly, eliminating one indirection layer. Identified in #2987 (Semantic Function Clustering analysis). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Removes the private writeJSONResponse helper from internal/server/http_helpers.go (a pure passthrough to internal/httputil.WriteJSONResponse) and updates server handlers to call httputil.WriteJSONResponse directly, reducing indirection in the internal/server package.
Changes:
- Deleted
writeJSONResponsefrominternal/server/http_helpers.go. - Updated
writeErrorResponseto callhttputil.WriteJSONResponsedirectly. - Updated 4 call sites across server handlers/middleware to use
httputil.WriteJSONResponseand added the required imports.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| internal/server/http_helpers.go | Removes the one-line wrapper and routes error responses directly through httputil.WriteJSONResponse. |
| internal/server/handlers.go | Replaces wrapper usage with httputil.WriteJSONResponse for /close responses and adds import. |
| internal/server/health.go | Replaces wrapper usage with httputil.WriteJSONResponse for /health response and adds import. |
| internal/server/routed.go | Replaces shutdown middleware response writer with httputil.WriteJSONResponse and adds import. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This was referenced Apr 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 This PR was created by Repo Assist, an automated AI assistant.
Summary
Removes the private
writeJSONResponsefunction frominternal/server/http_helpers.go, which was a pure one-liner passthrough tohttputil.WriteJSONResponsewith no added behaviour. The 4 call sites are updated to usehttputil.WriteJSONResponsedirectly.Motivation
Identified in #2987 (Semantic Function Clustering analysis) as a "< 30 min" quick win:
Changes
internal/server/http_helpers.gowriteJSONResponse;writeErrorResponsenow callshttputil.WriteJSONResponsedirectlyinternal/server/handlers.gohttputilimport; 2 call sites updatedinternal/server/health.gohttputilimport; 1 call site updatedinternal/server/routed.gohttputilimport; 1 call site updatedTest Status
go.mod) and the toolchain download is blocked by the network firewall. The changes are a mechanical rename with no logic changes — the type signatures and behaviour are identical to the wrapper being removed. CI in GitHub Actions should pass normally.Closes part of #2987 (the quick-win checklist item for
writeJSONResponse).