Add clarification for debug template reloading

main
Elnu 2 years ago
parent 01204ffc81
commit e00df6aac6

@ -15,11 +15,14 @@ func GenerateHandler(
methods []string, methods []string,
) Handler { ) Handler {
var tmpl *template.Template var tmpl *template.Template
if file != "" { //if file != "" {
tmpl = template.Must(template.ParseFiles(fmt.Sprintf("templates/%s", file))) // tmpl = template.Must(template.ParseFiles(fmt.Sprintf("templates/%s", file)))
} //}
return func(w http.ResponseWriter, r *http.Request) { return func(w http.ResponseWriter, r *http.Request) {
tmpl = template.Must(template.ParseFiles(fmt.Sprintf("templates/%s", file))) // Remove in production, enables live template reloading
if file != "" {
tmpl = template.Must(template.ParseFiles(fmt.Sprintf("templates/%s", file)))
}
for _, method := range methods { for _, method := range methods {
if method == r.Method { if method == r.Method {
goto ok goto ok