fix healthz endpoint when AMQP is disabled

This commit is contained in:
Steffen Vogel 2021-10-19 17:38:03 +02:00
parent a3b99dbd04
commit 49fe2e6e1f

View file

@ -54,11 +54,8 @@ func getHealth(c *gin.Context) {
} }
// check if connection to AMQP broker is alive if backend was started with AMQP client // check if connection to AMQP broker is alive if backend was started with AMQP client
url, err := configuration.GlobalConfig.StringOr("amqp.host", "not-set") url, err := configuration.GlobalConfig.StringOr("amqp.host", "")
if err != nil && url == "not-set" { if err != nil {
c.JSON(http.StatusOK, gin.H{})
return
} else if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{ c.JSON(http.StatusInternalServerError, gin.H{
"success:": false, "success:": false,
"message": err.Error(), "message": err.Error(),
@ -66,7 +63,10 @@ func getHealth(c *gin.Context) {
return return
} }
if len(url) != 0 { if url == "" {
c.Writer.WriteHeader(http.StatusNoContent)
return
} else {
err = helper.CheckConnection() err = helper.CheckConnection()
if err != nil { if err != nil {
log.Println(err.Error()) log.Println(err.Error())