Skip to content

Commit df807cf

Browse files
committed
fix: handle empty healthCheckPath in provider listener
1 parent a47d913 commit df807cf

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

protocol/rpcprovider/provider_listener.go

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -124,14 +124,17 @@ func NewProviderListener(ctx context.Context, networkAddress lavasession.Network
124124

125125
// Create HTTP server for health checks
126126
httpMux := http.NewServeMux()
127-
httpMux.HandleFunc(healthCheckPath, func(w http.ResponseWriter, r *http.Request) {
128-
if r.Method == http.MethodGet {
129-
w.WriteHeader(http.StatusOK)
130-
w.Write([]byte("Healthy"))
131-
} else {
132-
w.WriteHeader(http.StatusMethodNotAllowed)
133-
}
134-
})
127+
// Only register health check handler if path is provided
128+
if healthCheckPath != "" {
129+
httpMux.HandleFunc(healthCheckPath, func(w http.ResponseWriter, r *http.Request) {
130+
if r.Method == http.MethodGet {
131+
w.WriteHeader(http.StatusOK)
132+
w.Write([]byte("Healthy"))
133+
} else {
134+
w.WriteHeader(http.StatusMethodNotAllowed)
135+
}
136+
})
137+
}
135138
httpServer := &http.Server{Handler: httpMux}
136139
pl.httpServer = httpServer
137140

0 commit comments

Comments
 (0)