From 210b4eac6b97c561f668ccdcaa5adf51c470ff6d Mon Sep 17 00:00:00 2001 From: hunjixin <1084400399@qq.com> Date: Tue, 21 Feb 2023 09:52:36 +0800 Subject: [PATCH] feat: use thirty party healthcheck lib --- auth/route.go | 8 ++++++-- go.mod | 1 + go.sum | 2 ++ 3 files changed, 9 insertions(+), 2 deletions(-) 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..6d19a08 100644 --- a/go.mod +++ b/go.mod @@ -44,6 +44,7 @@ require ( github.com/deepmap/oapi-codegen v1.3.13 // indirect github.com/dgraph-io/ristretto v0.0.4-0.20210122082011-bb5d392ed82d // indirect github.com/dustin/go-humanize v1.0.0 // indirect + github.com/etherlabsio/healthcheck/v2 v2.0.0 // indirect github.com/gin-contrib/sse v0.1.0 // indirect github.com/go-playground/locales v0.13.0 // indirect github.com/go-playground/universal-translator v0.17.0 // indirect 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=