package internal import ( "log" "net/http" "os" ) type Controller struct{} func (c *Controller) Render(w http.ResponseWriter, r *http.Request, t string) { file, err := os.Open(t) if err != nil { log.Println(err) http.Error(w, err.Error(), 500) return } defer file.Close() fi, _ := file.Stat() http.ServeContent(w, r, file.Name(), fi.ModTime(), file) }