Skip to content

Commit

Permalink
feat: add health check endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
simonwep committed Nov 10, 2023
1 parent 5593822 commit 70fa4c4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,6 @@ ENV GENESIS_BUILD_VERSION=${GENESIS_BUILD_VERSION}
ENV GENESIS_BUILD_DATE=${GENESIS_BUILD_DATE}
ENV GENESIS_BUILD_COMMIT=${GENESIS_BUILD_COMMIT}

HEALTHCHECK CMD wget --no-verbose --tries=1 --spider http://localhost:8080/health || exit 1

CMD ["./genesis"]
12 changes: 12 additions & 0 deletions routes/health.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package routes

import (
"github.com/gin-gonic/gin"
"net/http"
)

func Health(c *gin.Context) {

// We assume, if the api is able to respond to this request, it is healthy.
c.Status(http.StatusOK)
}
3 changes: 3 additions & 0 deletions routes/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,8 @@ func SetupRoutes() *gin.Engine {
router.GET("/data/:key", DataByKey)
router.GET("/data", Data)

// Heal check endpoints
router.GET("/health", Health)

return router
}

0 comments on commit 70fa4c4

Please sign in to comment.