1
0
Fork 0
upl/readyz.go

24 lines
394 B
Go

package main
import (
"bytes"
"fmt"
"net/http"
)
func readyz(w http.ResponseWriter, req *http.Request) {
status := http.StatusOK
var msg bytes.Buffer
storeErr := globalStore.ping()
if storeErr != nil {
status = http.StatusServiceUnavailable
fmt.Fprintf(&msg, "store: %v\n", storeErr)
} else {
fmt.Fprintf(&msg, "store: ok\n")
}
w.WriteHeader(status)
w.Write(msg.Bytes())
}