diff --git a/auth/route.go b/auth/route.go index fcf7d9f..b730072 100644 --- a/auth/route.go +++ b/auth/route.go @@ -7,6 +7,8 @@ import ( "net/url" "time" + "github.com/etherlabsio/healthcheck/v2" + "github.com/filecoin-project/venus-auth/core" "github.com/filecoin-project/venus-auth/log" "github.com/gin-gonic/gin" @@ -17,9 +19,11 @@ func InitRouter(app OAuthApp) http.Handler { router.Use(CorsMiddleWare()) router.Use(RewriteAddressInUrl()) - router.GET("/status", func(c *gin.Context) { - c.String(http.StatusOK, "OK") + headlerFunc := healthcheck.HandlerFunc() + router.GET("/healthcheck", func(c *gin.Context) { + headlerFunc(c.Writer, c.Request) }) + router.GET("/version", func(c *gin.Context) { type version struct { Version string diff --git a/go.mod b/go.mod index 79e3b24..16b0db1 100644 --- a/go.mod +++ b/go.mod @@ -6,6 +6,7 @@ require ( github.com/BurntSushi/toml v0.3.1 github.com/DATA-DOG/go-sqlmock v1.5.0 github.com/dgraph-io/badger/v3 v3.2011.1 + github.com/etherlabsio/healthcheck/v2 v2.0.0 github.com/filecoin-project/go-address v0.0.5 github.com/filecoin-project/go-jsonrpc v0.1.3 github.com/fsnotify/fsnotify v1.4.9 diff --git a/go.sum b/go.sum index 27fd653..2699f3c 100644 --- a/go.sum +++ b/go.sum @@ -112,6 +112,8 @@ github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymF github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/etherlabsio/healthcheck/v2 v2.0.0 h1:oKq8cbpwM/yNGPXf2Sff6MIjVUjx/pGYFydWzeK2MpA= +github.com/etherlabsio/healthcheck/v2 v2.0.0/go.mod h1:huNVOjKzu6FI1eaO1CGD3ZjhrmPWf5Obu/pzpI6/wog= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/filecoin-project/go-address v0.0.5 h1:SSaFT/5aLfPXycUlFyemoHYhRgdyXClXCyDdNJKPlDM= github.com/filecoin-project/go-address v0.0.5/go.mod h1:jr8JxKsYx+lQlQZmF5i2U0Z+cGQ59wMIps/8YW/lDj8=