File tree 2 files changed +8
-12
lines changed
2 files changed +8
-12
lines changed Original file line number Diff line number Diff line change 1
1
package main
2
2
3
3
import (
4
+ "embed"
4
5
"encoding/base64"
5
6
"errors"
6
7
"fmt"
@@ -23,7 +24,6 @@ import (
23
24
24
25
"github.com/webdevops/azure-loganalytics-exporter/config"
25
26
"github.com/webdevops/azure-loganalytics-exporter/loganalytics"
26
- "github.com/webdevops/azure-loganalytics-exporter/templates"
27
27
)
28
28
29
29
const (
44
44
45
45
metricCache * cache.Cache
46
46
47
+ //go:embed templates/*.html
48
+ templates embed.FS
49
+
47
50
// Git version information
48
51
gitCommit = "<unknown>"
49
52
gitTag = "<unknown>"
@@ -160,10 +163,9 @@ func startHttpServer() {
160
163
})
161
164
162
165
// 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
+
167
169
mux .HandleFunc ("/query" , func (w http.ResponseWriter , r * http.Request ) {
168
170
cspNonce := base64 .StdEncoding .EncodeToString ([]byte (uuid .New ().String ()))
169
171
@@ -185,7 +187,7 @@ func startHttpServer() {
185
187
Nonce : cspNonce ,
186
188
}
187
189
188
- if err := reportTmpl . Execute ( w , templatePayload ); err != nil {
190
+ if err := tmpl . ExecuteTemplate ( w , "query.html" , templatePayload ); err != nil {
189
191
log .Error (err )
190
192
}
191
193
})
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments