@@ -35,8 +35,9 @@ import (
35
35
)
36
36
37
37
func serveOnPort (ctx context.Context , storageClient * storage.Client , predictor * predictionClient , port int , timeout time.Duration ) error {
38
+ mux := http .NewServeMux ()
38
39
39
- http .HandleFunc ("/" , func (w http.ResponseWriter , r * http.Request ) {
40
+ mux .HandleFunc ("/" , func (w http.ResponseWriter , r * http.Request ) {
40
41
ctx , cancel := context .WithTimeout (ctx , timeout )
41
42
defer cancel ()
42
43
status , body , err := processRequest (ctx , storageClient , predictor , r )
@@ -53,12 +54,12 @@ func serveOnPort(ctx context.Context, storageClient *storage.Client, predictor *
53
54
}
54
55
})
55
56
56
- http .HandleFunc ("/healthz" , func (w http.ResponseWriter , _ * http.Request ) {
57
+ mux .HandleFunc ("/healthz" , func (w http.ResponseWriter , _ * http.Request ) {
57
58
w .WriteHeader (http .StatusOK )
58
59
})
59
60
60
61
log .Println ("Listening for connections on port" , port )
61
- return http .ListenAndServe (":" + strconv .Itoa (port ), nil )
62
+ return http .ListenAndServe (":" + strconv .Itoa (port ), mux )
62
63
}
63
64
64
65
func processRequest (ctx context.Context , storageClient * storage.Client , predictor * predictionClient , r * http.Request ) (int , string , error ) {
0 commit comments