Flatten some if blocks
@@ -918,7 +918,12 @@ func (s *Service) handleReadyz(w http.ResponseWriter, r *http.Request) {
return
}
- if lAddr != "" {
+ if lAddr == "" {
+ w.WriteHeader(http.StatusServiceUnavailable)
+ w.Write([]byte("[+]node ok\n[+]leader does not exist"))
+ return
+ }
+
_, err = s.cluster.GetNodeAPIAddr(lAddr, timeout)
if err != nil {
w.WriteHeader(http.StatusServiceUnavailable)
@@ -927,10 +932,6 @@ func (s *Service) handleReadyz(w http.ResponseWriter, r *http.Request) {
}
w.WriteHeader(http.StatusOK)
w.Write([]byte("[+]node ok\n[+]leader ok"))
- return
- }
- w.WriteHeader(http.StatusServiceUnavailable)
- w.Write([]byte("[+]node ok\n[+]leader does not exist"))
}
func (s *Service) handleExecute(w http.ResponseWriter, r *http.Request) {
