Skip to content

Commit

Permalink
fix: make gosec happy
Browse files Browse the repository at this point in the history
  • Loading branch information
Primexz committed May 20, 2024
1 parent a251498 commit abed7b0
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/json"
"net/http"
"strconv"
"time"

"github.com/primexz/KrakenDCA/config"
log "github.com/sirupsen/logrus"
Expand Down Expand Up @@ -31,9 +32,18 @@ func StartServer() {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)

json.NewEncoder(w).Encode(Metrics)
if err := json.NewEncoder(w).Encode(Metrics); err != nil {
logger.WithError(err).Error("Failed to encode metrics.")
}
})

http.ListenAndServe(":"+strconv.Itoa(port), nil)
server := &http.Server{
Addr: ":" + strconv.Itoa(port),
ReadHeaderTimeout: 3 * time.Second,
}

if err := server.ListenAndServe(); err != nil {
logger.WithError(err).Error("Failed to start metrics server.")
}
}()
}

0 comments on commit abed7b0

Please sign in to comment.