A health check middleware for Gin.
$ go get -u github.com/RaMin0/gin-health-check
import (
healthcheck "github.com/RaMin0/gin-health-check"
"github.com/gin-gonic/gin"
)
func main() {
router := gin.Default()
router.Use(healthcheck.Default())
}
$ curl -iL -XGET -H "X-Health-Check: 1" http://localhost
# HTTP/1.1 200 OK
# Content-Length: 2
# Content-Type: text/plain; charset=utf-8
#
# ok
import (
"net/http"
healthcheck "github.com/RaMin0/gin-health-check"
"github.com/gin-gonic/gin"
)
func main() {
router := gin.Default()
router.Use(healthcheck.New(healthcheck.Config{
HeaderName: "X-Custom-Header",
HeaderValue: "customValue",
ResponseCode: http.StatusTeapot,
ResponseText: "teapot",
}))
}
$ curl -iL -XGET -H "X-Custom-Header: customValue" http://localhost
# HTTP/1.1 418 I'm a teapot
# Content-Length: 6
# Content-Type: text/plain; charset=utf-8
#
# teapot