Repository navigation
Conversation
9cb82ae to
7b4536d
Compare
There was a problem hiding this comment.
Pull Request Overview
This PR standardizes API responses to use JSON format throughout the system API, replacing simple HTTP status codes with structured JSON responses for both success and error cases.
- Implements consistent JSON response format for all API endpoints
- Introduces structured error responses with status codes and messages
- Adds helper methods for standardized JSON response handling
Reviewed Changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| systemapi/server.go | Adds JSON response helper methods and converts all endpoints to return structured JSON responses |
| systemapi/middleware.go | Updates basic auth middleware to return JSON error responses |
| systemapi/constants.go | Defines HTTP header and media type constants for consistent usage |
| systemapi-config.toml | Corrects filename reference in configuration comments |
| README.md | Updates example commands to use HTTPS and corrects configuration references |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| resp := httpErrorResp{ | ||
| Code: http.StatusUnauthorized, | ||
| Message: "Unauthorized", | ||
| } |
There was a problem hiding this comment.
The httpErrorResp struct is referenced here but not defined in this file. This creates a dependency on server.go that should be avoided. Consider moving the struct to a shared location like constants.go or creating a dedicated types file.
| s.respondOKJSON(w, map[string]string{ | ||
| "message": "File uploaded successfully", | ||
| "file": filename, | ||
| "size_bytes": fmt.Sprint(len(content)), //nolint:perfsprint |
There was a problem hiding this comment.
The nolint comment suggests awareness of a performance issue with fmt.Sprint. Consider using strconv.Itoa(len(content)) instead, which is more efficient for integer-to-string conversion.
📝 Summary
Make API calls return a JSON response, also JSON errors.
PR also fixes examples in the README.
✅ I have run these commands
make lintmake testgo mod tidy