Describe the bug
When using Go SDK to start HTTP server, adding custom health check for endpoint healthz or /healthz, like so s.AddHealthCheckHandler("/healthz", healthCheckHandler), it gets overridden by default health check, implemented in registerBaseHandler()here that called in Start() method.
2. Run `go run main.go`
3. Run `curl -v http://localhost:8080/healthz`, response 200, observe logs, no "custom health check" log printed.
4. Stop the server
5. Modify custom health check path, from `s.AddHealthCheckHandler("/healthz", healthCheckHandler)` to `s.AddHealthCheckHandler("/health", healthCheckHandler)`
6. Run `curl -v http://localhost:8080/health`, response 204 (as intended [here](https://github.com/dapr/go-sdk/blob/33180dd89a463a16781c02f60cbb909e8ccb6aef/service/http/health_check.go#L41)), observe logs, "custom health check" log printed.
7. Run `curl -v http://localhost:8080/healthz`, response 200, observe logs, no "custom health check" log printed.
**Expected behavior**
Using `s.AddHealthCheckHandler("/healthz", healthCheckHandler)` will allow using custom health check handler on the `healthz` endpoint and not being overridden by default empty implementation.
Describe the bug When using Go SDK to start HTTP server, adding custom health check for endpoint
healthz
or/healthz
, like sos.AddHealthCheckHandler("/healthz", healthCheckHandler)
, it gets overridden by default health check, implemented inregisterBaseHandler()
here that called inStart()
method.See: https://github.com/dapr/go-sdk/blob/33180dd89a463a16781c02f60cbb909e8ccb6aef/service/http/topic.go#L133-L136
This makes it impossible to use this endpoint for custom logic to provide more accurate app health.
To Reproduce
main.go
for example.import ( "context" "fmt" "log" "log/slog" "net/http"
)
func main() { s := daprd.NewService(":8080")
}
func healthCheckHandler(ctx context.Context) error { slog.Info("custom health check") return nil }