From 5aeb0808da010ab6ba064162cf69184b03c05ebf Mon Sep 17 00:00:00 2001 From: Andre Kully Date: Thu, 23 Dec 2021 16:54:45 +0100 Subject: [PATCH] change http router to gorilla/mux --- .gitignore | 3 ++- go.mod | 1 + go.sum | 1 + main.go | 3 ++- 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index b72222b..745881e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ mystrom-exporter output/* +*_string.go # Created by https://www.toptal.com/developers/gitignore/api/osx,intellij+all,windows # Edit at https://www.toptal.com/developers/gitignore?templates=osx,intellij+all,windows @@ -148,4 +149,4 @@ $RECYCLE.BIN/ # Windows shortcuts *.lnk -# End of https://www.toptal.com/developers/gitignore/api/osx,intellij+all,windows \ No newline at end of file +# End of https://www.toptal.com/developers/gitignore/api/osx,intellij+all,windows diff --git a/go.mod b/go.mod index 629a3bf..9570836 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,7 @@ module mystrom-exporter go 1.15 require ( + github.com/gorilla/mux v1.7.3 github.com/prometheus/client_golang v1.10.0 github.com/prometheus/common v0.18.0 ) diff --git a/go.sum b/go.sum index 7a50d30..ce3fb9d 100644 --- a/go.sum +++ b/go.sum @@ -99,6 +99,7 @@ github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+ github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= +github.com/gorilla/mux v1.7.3 h1:gnP5JzjVOuiZD07fKKToCAOjS0yOpj/qPETTXCCS6hw= github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= diff --git a/main.go b/main.go index e7e8bd7..eae08f9 100644 --- a/main.go +++ b/main.go @@ -9,6 +9,7 @@ import ( "strings" "time" + "github.com/gorilla/mux" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promhttp" "github.com/prometheus/common/log" @@ -69,7 +70,7 @@ func main() { // -- create a new registry for the exporter telemetry telemetryRegistry := setupMetrics() - router := http.NewServeMux() + router := mux.NewRouter() router.Handle(*metricsPath, promhttp.HandlerFor(telemetryRegistry, promhttp.HandlerOpts{})) router.HandleFunc(*devicePath, scrapeHandler) router.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {