Skip to content

Commit 7c218a5

Browse files
authored
fix: do not return a StripPrefix handler when building checker (#3559)
* fix: do not return a StripPrefix handler when building checker already doing the strip prefix https://github.com/tyler-lloyd/azure-container-networking/blob/40b6c443d62321ee61c134bf6573ed2de9813d50/cns/healthserver/server.go#L15 so doing it inside check builder is redunant and causes the /healthz endpoint to return a 404 * chore: tabs
1 parent a2a2ab8 commit 7c218a5

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

Diff for: cns/healthserver/healthz.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func NewHealthzHandlerWithChecks(cnsConfig *configuration.CNSConfig) (http.Handl
5555

5656
// strip prefix so that it runs through all checks registered on the handler.
5757
// otherwise it will look for a check named "healthz" and return a 404 if not there.
58-
return http.StripPrefix("/healthz", &healthz.Handler{
58+
return &healthz.Handler{
5959
Checks: checks,
60-
}), nil
60+
}, nil
6161
}

Diff for: cns/healthserver/healthz_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ func TestNewHealthzHandlerWithChecks(t *testing.T) {
198198

199199
responseRecorder := httptest.NewRecorder()
200200
healthHandler, err := NewHealthzHandlerWithChecks(tt.cnsConfig)
201+
healthHandler = http.StripPrefix("/healthz", healthHandler)
201202
require.NoError(t, err)
202203

203204
healthHandler.ServeHTTP(responseRecorder, httptest.NewRequest("GET", "/healthz", http.NoBody))

0 commit comments

Comments
 (0)