Пример #1
0
// ServeHTTP checks the `DEVELOPER` environment variable and if set, instructs all
// registered types to reload for each request.
func (tr *TemplateReloader) ServeHTTP(w http.ResponseWriter, r *http.Request) {

	// TODO: move template lifecycle management outside of the controlers

	if os.Getenv("DEVELOPER") != "" {
		log.Println("Reloading templates.")
		for _, r := range tr.reloadables {
			r.reloadTemplates()
		}
	}
}