Skip to content

Commit

Permalink
Merge pull request #35 from cpaillet/main
Browse files Browse the repository at this point in the history
fix(serializer): remove dead code
fix(api): handle fmt.Fprintf errors
  • Loading branch information
cpaillet authored Jun 18, 2024
2 parents 59529fc + 2933a3a commit 56158c8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 9 deletions.
4 changes: 2 additions & 2 deletions internal/api/router/endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ const wildcard = "*"

func healthCheck(w http.ResponseWriter, _ *http.Request, _ httprouter.Params) {
w.Header().Set(contentType, applicationJSON)
fmt.Fprintf(w, `{"status": "ok"}`)
_, _ = fmt.Fprintf(w, `{"status": "ok"}`)
}

func getVersion(w http.ResponseWriter, _ *http.Request, _ httprouter.Params) {
w.Header().Set(contentType, applicationJSON)
fmt.Fprintf(w, `{"version": "%s", "build_time": "%s", "build_user": "%s"}`, app.Info.Version, app.Info.BuildTime, app.Info.BuildUser)
_, _ = fmt.Fprintf(w, `{"version": "%s", "build_time": "%s", "build_user": "%s"}`, app.Info.Version, app.Info.BuildTime, app.Info.BuildUser)
}

func prometheusMetrics(h http.Handler) httprouter.Handle {
Expand Down
7 changes: 0 additions & 7 deletions internal/convertor/device/serializer.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package device

import (
"bytes"
"encoding/json"
"errors"

Expand Down Expand Up @@ -94,18 +93,12 @@ func (s *SafeRepository) GetDeviceOpenConfigJSON(hostname string) ([]byte, error

var config json.RawMessage
var err error
out := bytes.NewBuffer(nil)

if config, err = dev.GetCompactJSON(); err != nil {
log.Error().Err(err).Send()
return []byte(emptyJSON), err
}

if err := json.Compact(out, []byte(dev.Config.JSON)); err != nil {
log.Error().Err(err).Send()
return []byte(emptyJSON), err
}

if r, err := json.Marshal(config); err != nil {
log.Error().Err(err).Send()
return []byte(emptyJSON), err
Expand Down

0 comments on commit 56158c8

Please sign in to comment.