extract the landingpage out from the code to a variable
This commit is contained in:
parent
c49231374e
commit
f591467354
2 changed files with 10 additions and 9 deletions
15
main.go
15
main.go
|
@ -41,6 +41,13 @@ var (
|
|||
mystromDurationCounterVec *prometheus.CounterVec
|
||||
mystromRequestsCounterVec *prometheus.CounterVec
|
||||
)
|
||||
var landingPage = []byte(`<html>
|
||||
<head><title>myStrom switch report Exporter</title></head>
|
||||
<body>
|
||||
<h1>myStrom Exporter</h1>
|
||||
<p><a href='` + *metricsPath + `'>Metrics</a></p>
|
||||
</body>
|
||||
</html>`)
|
||||
|
||||
func main() {
|
||||
|
||||
|
@ -97,13 +104,7 @@ func main() {
|
|||
}),
|
||||
)
|
||||
router.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Write([]byte(`<html>
|
||||
<head><title>myStrom switch report Exporter</title></head>
|
||||
<body>
|
||||
<h1>myStrom Exporter</h1>
|
||||
<p><a href='` + *metricsPath + `'>Metrics</a></p>
|
||||
</body>
|
||||
</html>`))
|
||||
w.Write(landingPage)
|
||||
})
|
||||
log.Infoln("Listening on address " + *listenAddress)
|
||||
log.Fatal(http.ListenAndServe(*listenAddress, router))
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue