Commit c54097d9 authored by Clayton Coleman's avatar Clayton Coleman

DefaultMux should only register the first time

parent 1f628f23
...@@ -20,6 +20,7 @@ import ( ...@@ -20,6 +20,7 @@ import (
"bytes" "bytes"
"fmt" "fmt"
"net/http" "net/http"
"sync"
) )
// HealthzChecker is a named healthz check. // HealthzChecker is a named healthz check.
...@@ -28,9 +29,13 @@ type HealthzChecker interface { ...@@ -28,9 +29,13 @@ type HealthzChecker interface {
Check(req *http.Request) error Check(req *http.Request) error
} }
var defaultHealthz = sync.Once{}
// DefaultHealthz installs the default healthz check to the http.DefaultServeMux. // DefaultHealthz installs the default healthz check to the http.DefaultServeMux.
func DefaultHealthz(checks ...HealthzChecker) { func DefaultHealthz(checks ...HealthzChecker) {
InstallHandler(http.DefaultServeMux, checks...) defaultHealthz.Do(func() {
InstallHandler(http.DefaultServeMux, checks...)
})
} }
// PingHealthz returns true automatically when checked // PingHealthz returns true automatically when checked
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment