Documentation ¶
Overview ¶
Example (CustomHandler) ¶
// Example code r := gin.Default() r.GET("livez", NewHandler(NewDefaultHandlerConfig())) readyzChecks := []checks.Check{checks.NewPingCheck(), checks.NewEnvCheck("DB_HOST")} r.GET("readyz", NewHandler(NewDefaultHandlerConfigFor(readyzChecks...))) // Simulate request dummyRequest(r, "/livez") dummyRequest(r, "/readyz?verbose") dummyRequest(r, "/readyz?verbose&excludes=Env-DB_HOST")
Output: 200 OK 503 [+] Ping ok [-] Env-DB_HOST fail health check failed 200 [+] Ping ok health check passed
Example (Register) ¶
// Example code r := gin.Default() _ = Register(&r.RouterGroup) // Simulate request dummyRequest(r, "/healthz")
Output: 200 OK
Example (RegisterFor) ¶
// Example code r := gin.Default() config := NewDefaultConfig() config.Verbose = true _ = RegisterFor(&r.RouterGroup, config) // Simulate request dummyRequest(r, "/healthz")
Output: 200 [+] Ping ok health check passed
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func NewHandler ¶
func NewHandler(conf HandlerConfig) gin.HandlerFunc
NewHandler creates a new health check handler that can be used to check if the application is running.
func Register ¶
func Register(r *gin.RouterGroup) error
Register registers a default health check handler with the specified router group.
func RegisterFor ¶
func RegisterFor(r *gin.RouterGroup, configs ...Config) error
RegisterFor registers one or more health check handlers with the specified router group and configurations.
Types ¶
type Config ¶
type Config struct { HTTPMethod string Endpoint string HandlerConfig }
Config represents the configuration for the health check.
func NewDefaultConfig ¶
func NewDefaultConfig() Config
NewDefaultConfig creates a new default health check configuration.
func NewDefaultConfigFor ¶
NewDefaultConfigFor creates a new default health check configuration for the specified checks.
type FailureNotification ¶
FailureNotification represents the configuration for failure notifications.
type HandlerConfig ¶
type HandlerConfig struct { Verbose bool Excludes []string Checks []checks.Check FailureNotification }
HandlerConfig represents the configuration for the health check handler.
func NewDefaultHandlerConfig ¶
func NewDefaultHandlerConfig() HandlerConfig
NewDefaultHandlerConfig creates a new default health check handler configuration.
func NewDefaultHandlerConfigFor ¶
func NewDefaultHandlerConfigFor(cs ...checks.Check) HandlerConfig
NewDefaultHandlerConfigFor creates a new default health check handler configuration for the specified checks.