Skip to content

Commit

Permalink
Corrected issues from linting
Browse files Browse the repository at this point in the history
  • Loading branch information
mconfalonieri committed Nov 1, 2023
1 parent f9ee742 commit 64c38ed
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions internal/server/health.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,23 +56,31 @@ type HealthServer struct {
// healthy flag is set to "true" and 503/Service Unavailable otherwise.
func (s HealthServer) livenessHandler(w http.ResponseWriter, r *http.Request) {
healthy := s.status.IsHealthy()
if healthy == true {
w.Write([]byte(http.StatusText(http.StatusOK)))
var err error
if healthy {
_, err = w.Write([]byte(http.StatusText(http.StatusOK)))
} else {
w.WriteHeader(http.StatusServiceUnavailable)
w.Write([]byte(http.StatusText(http.StatusServiceUnavailable)))
_, err = w.Write([]byte(http.StatusText(http.StatusServiceUnavailable)))
}
if err != nil {
log.Warn("Could not answer to a liveness probe: ", err.Error())
}
}

// readinessHandler checks if the server is ready. It writes 200/OK if the
// healthy flag is set to "true" and 503/Service Unavailable otherwise.
func (s HealthServer) readinessHandler(w http.ResponseWriter, r *http.Request) {
ready := s.status.IsReady()
if ready == true {
w.Write([]byte(http.StatusText(http.StatusOK)))
var err error
if ready {
_, err = w.Write([]byte(http.StatusText(http.StatusOK)))
} else {
w.WriteHeader(http.StatusServiceUnavailable)
w.Write([]byte(http.StatusText(http.StatusServiceUnavailable)))
_, err = w.Write([]byte(http.StatusText(http.StatusServiceUnavailable)))
}
if err != nil {
log.Warn("Could not answer to a readiness probe: ", err.Error())
}
}

Expand Down

0 comments on commit 64c38ed

Please sign in to comment.