File tree Expand file tree Collapse file tree 2 files changed +8
-12
lines changed Expand file tree Collapse file tree 2 files changed +8
-12
lines changed Original file line number Diff line number Diff line change 11package main
22
33import (
4+ "embed"
45 "encoding/base64"
56 "errors"
67 "fmt"
@@ -23,7 +24,6 @@ import (
2324
2425 "github.com/webdevops/azure-loganalytics-exporter/config"
2526 "github.com/webdevops/azure-loganalytics-exporter/loganalytics"
26- "github.com/webdevops/azure-loganalytics-exporter/templates"
2727)
2828
2929const (
4444
4545 metricCache * cache.Cache
4646
47+ //go:embed templates/*.html
48+ templates embed.FS
49+
4750 // Git version information
4851 gitCommit = "<unknown>"
4952 gitTag = "<unknown>"
@@ -160,10 +163,9 @@ func startHttpServer() {
160163 })
161164
162165 // report
163- reportTmpl , err := template .New ("report" ).Parse (templates .QueryHtml )
164- if err != nil {
165- log .Panicf ("failed to parse query.html: %v" , err .Error ())
166- }
166+
167+ tmpl := template .Must (template .ParseFS (templates , "templates/*.html" ))
168+
167169 mux .HandleFunc ("/query" , func (w http.ResponseWriter , r * http.Request ) {
168170 cspNonce := base64 .StdEncoding .EncodeToString ([]byte (uuid .New ().String ()))
169171
@@ -185,7 +187,7 @@ func startHttpServer() {
185187 Nonce : cspNonce ,
186188 }
187189
188- if err := reportTmpl . Execute ( w , templatePayload ); err != nil {
190+ if err := tmpl . ExecuteTemplate ( w , "query.html" , templatePayload ); err != nil {
189191 log .Error (err )
190192 }
191193 })
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments