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