search frontend
This commit is contained in:
parent
10140231a6
commit
d59c119f75
6 changed files with 46 additions and 16 deletions
|
|
@ -26,14 +26,14 @@ func (h *Server) loadTemplates() {
|
|||
}
|
||||
}
|
||||
|
||||
func (s *Server) render(fetch fetcher, templateName string) http.HandlerFunc {
|
||||
func (s *Server) render(fetch fetcher, templateFile string, templateEntry string) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
data, code, err := fetch(r)
|
||||
if err != nil {
|
||||
logging.ErrorPage(err, code).ServeHTTP(w, r)
|
||||
return
|
||||
}
|
||||
err = s.tmpl[templateName].ExecuteTemplate(w, "layout", data)
|
||||
err = s.tmpl[templateFile].ExecuteTemplate(w, templateEntry, data)
|
||||
if err != nil {
|
||||
logging.ErrorPage(err, http.StatusInternalServerError).ServeHTTP(w, r)
|
||||
return
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue