From f5914673543279e3e06396a32f4141b3d4f717bb Mon Sep 17 00:00:00 2001 From: Andre Kully Date: Thu, 23 Dec 2021 16:48:29 +0100 Subject: [PATCH] extract the landingpage out from the code to a variable --- main.go | 15 ++++++++------- pkg/mystrom/mystrom.go | 4 ++-- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/main.go b/main.go index dc8ae82..4b71a50 100644 --- a/main.go +++ b/main.go @@ -41,6 +41,13 @@ var ( mystromDurationCounterVec *prometheus.CounterVec mystromRequestsCounterVec *prometheus.CounterVec ) +var landingPage = []byte(` +myStrom switch report Exporter + +

myStrom Exporter

+

Metrics

+ +`) func main() { @@ -97,13 +104,7 @@ func main() { }), ) router.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { - w.Write([]byte(` - myStrom switch report Exporter - -

myStrom Exporter

-

Metrics

- - `)) + w.Write(landingPage) }) log.Infoln("Listening on address " + *listenAddress) log.Fatal(http.ListenAndServe(*listenAddress, router)) diff --git a/pkg/mystrom/mystrom.go b/pkg/mystrom/mystrom.go index 8b00aea..e54c53b 100644 --- a/pkg/mystrom/mystrom.go +++ b/pkg/mystrom/mystrom.go @@ -15,8 +15,8 @@ const namespace = "mystrom" type switchReport struct { Power float64 `json:"power"` WattPerSec float64 `json:"Ws"` - Relay bool `json:relay` - Temperature float64 `json:"temperature` + Relay bool `json:"relay"` + Temperature float64 `json:"temperature"` } type Exporter struct {