Erzeuge Templates zentral und nicht pro Aufruf
This commit is contained in:
parent
886ccc0dcb
commit
43b3631da2
7 changed files with 32 additions and 45 deletions
|
@ -1,7 +1,6 @@
|
|||
package controllers
|
||||
|
||||
import (
|
||||
"html/template"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
|
@ -11,21 +10,16 @@ func (b *BaseHandler) ConfirmRequestHandler(w http.ResponseWriter, req *http.Req
|
|||
|
||||
if err != nil {
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
tmpl, _ := template.ParseFiles("templates/requestNotFound.html")
|
||||
tmpl.Execute(w, struct{}{})
|
||||
Templates.ExecuteTemplate(w, "requestNotFound.html", struct{}{})
|
||||
return
|
||||
}
|
||||
|
||||
err = b.requestRepo.Execute(request)
|
||||
if err != nil {
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
tmpl, _ := template.ParseFiles("templates/executeFailure.html")
|
||||
tmpl.Execute(w, err.Error())
|
||||
Templates.ExecuteTemplate(w, "executeFailure.html", err.Error())
|
||||
return
|
||||
}
|
||||
tmpl, err := template.ParseFiles("templates/executeSuccess.html")
|
||||
if err != nil {
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
}
|
||||
tmpl.Execute(w, struct{}{})
|
||||
Templates.ExecuteTemplate(w, "executeSuccess.html", struct{}{})
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue