Add a handler to your http.Server that returns a 200 status code to indicate the application is healthy.
package main
import (
"log"
"net/http"
)
func main() {
http.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
w.Write([]byte("OK"))
})
log.Fatal(http.ListenAndServe(":8080", nil))
}
Start your server and verify the endpoint by visiting http://localhost:8080/health.