@@ 4,6 4,7 @@ import (
"encoding/json"
"net/http"
"os"
+ "sync/atomic"
"github.com/go-chi/chi/v5"
)
@@ 75,11 76,11 @@ func AddBasicHealthRoute(r *chi.Mux) {
// AddSettleHealthRoute adds a route on ‘/health’ that returns “UP” or
// “UNSETTLED” depending on the given boolean.
-func AddSettleHealthRoute(r *chi.Mux, loadedFlag *bool) {
+func AddSettleHealthRoute(r *chi.Mux, loadedFlag *atomic.Bool) {
r.Get("/health", func(w http.ResponseWriter, req *http.Request) {
var err error
- if *loadedFlag {
+ if loadedFlag.Load() {
_, err = w.Write([]byte(UP))
} else {
// Consul interprets HTTP 429 as that a service check should have the “warning”