diff --git a/cns/healthserver/healthz.go b/cns/healthserver/healthz.go index 45bc2f303c..d3336e5345 100644 --- a/cns/healthserver/healthz.go +++ b/cns/healthserver/healthz.go @@ -55,7 +55,7 @@ func NewHealthzHandlerWithChecks(cnsConfig *configuration.CNSConfig) (http.Handl // strip prefix so that it runs through all checks registered on the handler. // otherwise it will look for a check named "healthz" and return a 404 if not there. - return http.StripPrefix("/healthz", &healthz.Handler{ + return &healthz.Handler{ Checks: checks, - }), nil + }, nil } diff --git a/cns/healthserver/healthz_test.go b/cns/healthserver/healthz_test.go index 805509a1f4..8b6e55df3e 100644 --- a/cns/healthserver/healthz_test.go +++ b/cns/healthserver/healthz_test.go @@ -198,6 +198,7 @@ func TestNewHealthzHandlerWithChecks(t *testing.T) { responseRecorder := httptest.NewRecorder() healthHandler, err := NewHealthzHandlerWithChecks(tt.cnsConfig) + healthHandler = http.StripPrefix("/healthz", healthHandler) require.NoError(t, err) healthHandler.ServeHTTP(responseRecorder, httptest.NewRequest("GET", "/healthz", http.NoBody))