dont use templates
This commit is contained in:
27
main.go
27
main.go
@@ -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) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user