Skip to content

Commit 170a623

Browse files
authored
feat: add root-endpoint to container (#420)
* feat: add root-endpoint to container * docs: typo under deprecated endpoints
1 parent d12ba8c commit 170a623

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ There is a swagger-generated documentation available for download on the [GitHub
130130

131131
Those are the current existing endpoints.
132132

133+
- GET `/`
133134
- GET `/ping`
134135
- GET `/healthz`
135136
- GET `/readyz`
@@ -159,7 +160,7 @@ Those are the current existing endpoints.
159160

160161
In addition to the deprecated API versions like v1, v2 and v3, there are also some endpoints that are deprecated. As of now, those are:
161162

162-
- GET `/healthz`
163+
- GET `/health`
163164

164165
### Restricted endpoints
165166

src/webserver.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ func runWebServer() {
136136
})
137137

138138
// health endpoints for kubernetes
139+
router.GET("/", rootz)
139140
router.GET("/health", healthz)
140141
router.GET("/healthz", healthz)
141142
router.GET("/readyz", readyz)
@@ -1305,6 +1306,15 @@ func TibiaDataHTMLDataCollector(TibiaDataRequest TibiaDataRequestStruct) (string
13051306
return data, nil
13061307
}
13071308

1309+
// rootz is a root path (for helm-testing)
1310+
func rootz(c *gin.Context) {
1311+
if !isReady.Load() {
1312+
c.JSON(http.StatusServiceUnavailable, gin.H{"error": http.StatusText(http.StatusServiceUnavailable)})
1313+
return
1314+
}
1315+
TibiaDataAPIHandleResponse(c, "rootz", gin.H{"message": "TibiaData API up and running."})
1316+
}
1317+
13081318
// healthz is a k8s liveness probe
13091319
func healthz(c *gin.Context) {
13101320
c.JSON(http.StatusOK, gin.H{"status": http.StatusText(http.StatusOK)})

src/webserver_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,9 @@ func TestFakeToUpCodeCoverage(t *testing.T) {
244244
tibiaWorldsWorld(c)
245245
assert.Equal(http.StatusOK, w.Code)
246246

247+
rootz(c)
248+
assert.Equal(http.StatusOK, w.Code)
249+
247250
healthz(c)
248251
assert.Equal(http.StatusOK, w.Code)
249252

0 commit comments

Comments
 (0)