We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a9e37e1 commit e86fb53Copy full SHA for e86fb53
pkg/handler/handler.go
@@ -4,11 +4,14 @@ import (
4
"github.com/gin-gonic/gin"
5
"github.com/thecasualcoder/dobby/pkg/config"
6
"os"
7
+ "strconv"
8
)
9
10
+var statusCode = 200
11
+
12
// Health return the dobby health status
13
func Health(c *gin.Context) {
- c.JSON(200, gin.H{"healthy": true})
14
+ c.JSON(statusCode, gin.H{"healthy": true})
15
}
16
17
// Version return dobby version
@@ -20,3 +23,13 @@ func Version(c *gin.Context) {
20
23
21
24
c.JSON(200, gin.H{"version": version})
22
25
26
27
+func init() {
28
+ healthy, err := strconv.ParseBool(os.Getenv("HEALTH"))
29
30
+ if err != nil {
31
+ statusCode = 200
32
+ } else if !healthy {
33
+ statusCode = 500
34
+ }
35
+}
0 commit comments