From 49bb71fad5c857edbb060b1b5c8962bbd227cbb9 Mon Sep 17 00:00:00 2001 From: Martin Hebnes Pedersen Date: Fri, 13 Oct 2023 23:06:04 +0200 Subject: [PATCH] Cleanup of HTTP routing No need to use both gorilla's mux and http's ServeMux. --- http.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/http.go b/http.go index 2982338c..f508d14e 100644 --- a/http.go +++ b/http.go @@ -121,16 +121,18 @@ func ListenAndServe(ctx context.Context, addr string) error { r.HandleFunc("/api/current_gps_position", positionHandler).Methods("GET") r.HandleFunc("/api/qsy", qsyHandler).Methods("POST") r.HandleFunc("/api/rmslist", rmslistHandler).Methods("GET") + + r.PathPrefix("/dist/").Handler(distHandler()) r.HandleFunc("/ws", wsHandler) r.HandleFunc("/ui", uiHandler()).Methods("GET") r.HandleFunc("/", rootHandler).Methods("GET") - http.Handle("/", r) - http.Handle("/dist/", distHandler()) - websocketHub = NewWSHub() - srv := http.Server{Addr: addr} + srv := http.Server{ + Addr: addr, + Handler: r, + } errs := make(chan error, 1) go func() { errs <- srv.ListenAndServe()