Bereinige signalstarke Linter-Funde
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
parent
f3dd37fb3d
commit
f8a57b3e6b
5 changed files with 16 additions and 8 deletions
|
|
@ -17,7 +17,7 @@ type recordingReporter struct {
|
||||||
err error
|
err error
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *recordingReporter) Send(ctx context.Context, snapshot statusreporter.Snapshot) error {
|
func (r *recordingReporter) Send(_ context.Context, _ statusreporter.Snapshot) error {
|
||||||
r.callCount++
|
r.callCount++
|
||||||
return r.err
|
return r.err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -70,10 +70,14 @@ func (r *Reporter) Send(ctx context.Context, snapshot Snapshot) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("send status request: %w", err)
|
return fmt.Errorf("send status request: %w", err)
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
statusCode := resp.StatusCode
|
||||||
|
statusText := resp.Status
|
||||||
|
if err := resp.Body.Close(); err != nil {
|
||||||
|
return fmt.Errorf("close status response body: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
if resp.StatusCode != http.StatusOK {
|
if statusCode != http.StatusOK {
|
||||||
return fmt.Errorf("unexpected status response: %s", resp.Status)
|
return fmt.Errorf("unexpected status response: %s", statusText)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,10 @@ func writeError(w http.ResponseWriter, status int, code, message string, details
|
||||||
}
|
}
|
||||||
|
|
||||||
func decodeJSON(r *http.Request, dest any) error {
|
func decodeJSON(r *http.Request, dest any) error {
|
||||||
defer r.Body.Close()
|
defer func() {
|
||||||
|
if err := r.Body.Close(); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}()
|
||||||
return json.NewDecoder(r.Body).Decode(dest)
|
return json.NewDecoder(r.Body).Decode(dest)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ package httpapi
|
||||||
|
|
||||||
import "net/http"
|
import "net/http"
|
||||||
|
|
||||||
func handleMeta(w http.ResponseWriter, r *http.Request) {
|
func handleMeta(w http.ResponseWriter, _ *http.Request) {
|
||||||
writeJSON(w, http.StatusOK, map[string]any{
|
writeJSON(w, http.StatusOK, map[string]any{
|
||||||
"service": "morz-infoboard-backend",
|
"service": "morz-infoboard-backend",
|
||||||
"version": "dev",
|
"version": "dev",
|
||||||
|
|
|
||||||
|
|
@ -7,14 +7,14 @@ import (
|
||||||
func NewRouter() http.Handler {
|
func NewRouter() http.Handler {
|
||||||
mux := http.NewServeMux()
|
mux := http.NewServeMux()
|
||||||
|
|
||||||
mux.HandleFunc("GET /healthz", func(w http.ResponseWriter, r *http.Request) {
|
mux.HandleFunc("GET /healthz", func(w http.ResponseWriter, _ *http.Request) {
|
||||||
writeJSON(w, http.StatusOK, map[string]string{
|
writeJSON(w, http.StatusOK, map[string]string{
|
||||||
"status": "ok",
|
"status": "ok",
|
||||||
"service": "morz-infoboard-backend",
|
"service": "morz-infoboard-backend",
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
mux.HandleFunc("GET /api/v1", func(w http.ResponseWriter, r *http.Request) {
|
mux.HandleFunc("GET /api/v1", func(w http.ResponseWriter, _ *http.Request) {
|
||||||
writeJSON(w, http.StatusOK, map[string]any{
|
writeJSON(w, http.StatusOK, map[string]any{
|
||||||
"name": "morz-infoboard-backend",
|
"name": "morz-infoboard-backend",
|
||||||
"version": "dev",
|
"version": "dev",
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue