~ogham/doom

ff63d7c705c8c82ea461ac62edc1f0e9d5d60b79 — Benjamin Sago 1 year, 10 months ago 2cd1da6
go crazy with the cheez-whiz
1 files changed, 3 insertions(+), 2 deletions(-)

M mroutes/health.go
M mroutes/health.go => mroutes/health.go +3 -2
@@ 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”