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"
|
||||||
"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) {
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user