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
url, err := configuration.GlobalConfig.StringOr("amqp.host", "not-set")
if err != nil && url == "not-set" {
c.JSON(http.StatusOK, gin.H{})
return
} else if err != nil {
url, err := configuration.GlobalConfig.StringOr("amqp.host", "")
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{
"success:": false,
"message": err.Error(),
@ -66,7 +63,10 @@ func getHealth(c *gin.Context) {
return
}
if len(url) != 0 {
if url == "" {
c.Writer.WriteHeader(http.StatusNoContent)
return
} else {
err = helper.CheckConnection()
if err != nil {
log.Println(err.Error())