aboutsummaryrefslogtreecommitdiff
path: root/util.go
blob: 6381bff130597130c81a4ec95fe2091d2f85c650 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package main

import (
	"fmt"
	"html/template"
	"log"
	"net/http"
)

func reloadTemplate(t **template.Template, files ...string) error {
	tmpl, err := template.ParseFiles(files...)
	if err != nil {
		msg := fmt.Sprintf("Template load error: %v", err)
		log.Println(msg)
	} else {
		*t = tmpl
	}
	return err
}

func templateError(err error, w http.ResponseWriter) {
	msg := "Template execution error"
	http.Error(w, msg, http.StatusInternalServerError)
	log.Println(msg)
}