Skip to content

RaMin0/gin-health-check

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gin-health-check

Build Status CodeCov GoDoc License

A health check middleware for Gin.

Installation

$ go get -u github.com/RaMin0/gin-health-check

Usage

Default Config

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

Custom Config

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

About

A health check middleware for Gin

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages