@@ -182,9 +182,10 @@ func Run(ctx context.Context, args []string) int {
182
182
config .Bind = maybeAddPort (config .Bind , "9042" )
183
183
config .HttpBind = maybeAddPort (config .HttpBind , "8000" )
184
184
185
- maybeAddHealthCheck (p )
185
+ var mux http.ServeMux
186
+ maybeAddHealthCheck (p , & mux )
186
187
187
- err = listenAndServe (p , ctx , logger )
188
+ err = listenAndServe (p , & mux , ctx , logger )
188
189
if err != nil {
189
190
cliCtx .Errorf ("%v" , err )
190
191
return 1
@@ -213,13 +214,13 @@ func parseProtocolVersion(s string) (version primitive.ProtocolVersion, ok bool)
213
214
}
214
215
215
216
// maybeAddHealthCheck checks the config and adds handlers for health checks if required.
216
- func maybeAddHealthCheck (p * Proxy ) {
217
+ func maybeAddHealthCheck (p * Proxy , mux * http. ServeMux ) {
217
218
if config .HealthCheck {
218
- http .HandleFunc (livenessPath , func (writer http.ResponseWriter , request * http.Request ) {
219
+ mux .HandleFunc (livenessPath , func (writer http.ResponseWriter , request * http.Request ) {
219
220
writer .WriteHeader (http .StatusOK )
220
221
_ , _ = writer .Write ([]byte ("ok" ))
221
222
})
222
- http .HandleFunc (readinessPath , func (writer http.ResponseWriter , request * http.Request ) {
223
+ mux .HandleFunc (readinessPath , func (writer http.ResponseWriter , request * http.Request ) {
223
224
header := writer .Header ()
224
225
header .Set ("Content-Type" , "application/json" )
225
226
@@ -252,11 +253,11 @@ func maybeAddPort(addr string, defaultPort string) string {
252
253
}
253
254
254
255
// listenAndServe correctly handles serving both the proxy and an HTTP server simultaneously.
255
- func listenAndServe (p * Proxy , ctx context.Context , logger * zap.Logger ) (err error ) {
256
+ func listenAndServe (p * Proxy , mux * http. ServeMux , ctx context.Context , logger * zap.Logger ) (err error ) {
256
257
var wg sync.WaitGroup
257
258
258
259
ch := make (chan error )
259
- server := http.Server {Addr : config .HttpBind }
260
+ server := http.Server {Addr : config .HttpBind , Handler : mux }
260
261
261
262
numServers := 1 // Without the HTTP server
262
263
0 commit comments