From f059d52d43f2cc8c7f0651c6e52b2c5e48ef1ea6 Mon Sep 17 00:00:00 2001 From: Holger Obermaier <40787752+ho-ob@users.noreply.github.com> Date: Wed, 11 Oct 2023 17:19:39 +0200 Subject: [PATCH] Use DefaultServeMux instead of github.com/gorilla/mux --- receivers/httpReceiver.go | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/receivers/httpReceiver.go b/receivers/httpReceiver.go index c243e41..ac7aa03 100644 --- a/receivers/httpReceiver.go +++ b/receivers/httpReceiver.go @@ -12,7 +12,6 @@ import ( cclog "github.com/ClusterCockpit/cc-metric-collector/pkg/ccLogger" lp "github.com/ClusterCockpit/cc-metric-collector/pkg/ccMetric" - "github.com/gorilla/mux" influx "github.com/influxdata/line-protocol/v2/lineprotocol" ) @@ -39,7 +38,6 @@ type HttpReceiver struct { receiver meta map[string]string config HttpReceiverConfig - router *mux.Router server *http.Server wg sync.WaitGroup } @@ -93,16 +91,16 @@ func (r *HttpReceiver) Init(name string, config json.RawMessage) error { uri := addr + p cclog.ComponentDebug(r.name, "INIT", "listen on:", uri) - // Create new router and register p as path - r.router = mux.NewRouter() - r.router.Path(p).HandlerFunc(r.ServerHttp) + // Register handler function r.ServerHttp for path p in the DefaultServeMux + http.HandleFunc(p, r.ServerHttp) - // Create http server, with router as handler + // Create http server r.server = &http.Server{ Addr: addr, - Handler: r.router, + Handler: nil, // handler to invoke, http.DefaultServeMux if nil IdleTimeout: r.config.idleTimeout, } + return nil }