Skip to content

dimiro1/healthz

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Healthz

Healthz is a straightforward Go package for adding health check HTTP handlers to your web apps. It's ideal for Kubernetes-like environments to ensure your service is running smoothly.

Features

Just two functions - simple and to the point.

Installation

Run:

go get github.com/dimiro1/healthz

Usage

Custom Health Check

package main

import (
	"net/http"
	"github.com/dimiro1/healthz"
)

func main() {
	healthCheckLogic := func() bool {
		// Define your health check logic here
		return true // return true if healthy, false otherwise
	}

	http.Handle("/healthz", healthz.Check(healthCheckLogic))
	_ = http.ListenAndServe(":8080", nil)
}

Always Healthy

For a basic always-healthy endpoint:

package main

import (
	"net/http"
	"github.com/dimiro1/healthz"
)

func main() {
	http.HandleFunc("/healthz", healthz.AlwaysUp)
	_ = http.ListenAndServe(":8080", nil)
}

LICENSE

This project is licensed under the MIT License.

About

Straightforward health package

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages