rework template rendering, cache parsed templates
adapt error wrapping principle
This commit is contained in:
parent
7a1448d6f9
commit
f04396809d
21 changed files with 175 additions and 82 deletions
|
@ -7,6 +7,7 @@ import (
|
|||
"net/mail"
|
||||
"officeHours/config"
|
||||
"officeHours/models"
|
||||
"officeHours/templating"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
@ -149,7 +150,7 @@ func (b *BaseHandler) AddOfficeHourHandler(w http.ResponseWriter, req *http.Requ
|
|||
id, err := b.officeHourRepo.Add(officeHour)
|
||||
if err != nil {
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
b.serveTemplate(w, "addFailure", err)
|
||||
templating.ServeTemplate(w, "addFailure", err)
|
||||
return
|
||||
}
|
||||
officeHour, err = b.officeHourRepo.FindById(id)
|
||||
|
@ -160,7 +161,7 @@ func (b *BaseHandler) AddOfficeHourHandler(w http.ResponseWriter, req *http.Requ
|
|||
if err != nil {
|
||||
log.Printf("Error adding request: %s", err.Error())
|
||||
}
|
||||
b.serveTemplate(w, "addSuccess", nil)
|
||||
templating.ServeTemplate(w, "addSuccess", nil)
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -172,5 +173,5 @@ func (b *BaseHandler) writeAddOfficeHourMask(w http.ResponseWriter, req *http.Re
|
|||
if len(data.Errors) != 0 {
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
}
|
||||
b.serveTemplate(w, "addMask", data)
|
||||
templating.ServeTemplate(w, "addMask", data)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue