dont use templates
Some checks failed
Build and Publish / BuildAndDeploy (push) Successful in 2m51s
Build and Publish / BuildAndDeployAmd64 (push) Has been cancelled

This commit is contained in:
matst80
2025-05-13 18:19:42 +02:00
parent 79fc990a98
commit 4cb181578a

27
main.go
View File

@@ -7,7 +7,6 @@ import (
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
"github.com/prometheus/client_golang/prometheus/promhttp"
"html/template"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
"log"
@@ -122,7 +121,7 @@ var tpl = `<!DOCTYPE html>
</head>
<body>
{{ .HTMLSnippet }}
%s
</body>
</html>
`
@@ -232,15 +231,9 @@ func main() {
w.Write([]byte(err.Error()))
return
}
t, err := template.New("checkout").Parse(tpl)
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
w.Write([]byte(err.Error()))
}
err = t.Execute(w, &order)
if err != nil {
log.Printf("Error executing template: %v\n", err)
}
w.Header().Set("Content-Type", "text/html; charset=utf-8")
w.WriteHeader(http.StatusOK)
w.Write([]byte(fmt.Sprintf(tpl, order.HTMLSnippet)))
})
mux.HandleFunc("/confirmation/{order_id}", func(w http.ResponseWriter, r *http.Request) {
@@ -253,15 +246,9 @@ func main() {
return
}
t, err := template.New("confirmation").Parse(tpl)
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
w.Write([]byte(err.Error()))
}
err = t.Execute(w, &order)
if err != nil {
log.Printf("Error executing template: %v\n", err)
}
w.Header().Set("Content-Type", "text/html; charset=utf-8")
w.WriteHeader(http.StatusOK)
w.Write([]byte(fmt.Sprintf(tpl, order.HTMLSnippet)))
})
mux.HandleFunc("/push", func(w http.ResponseWriter, r *http.Request) {