Attemping to fix bulk upload problem
This commit is contained in:
+8
-3
@@ -1,9 +1,10 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"html/template"
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type Templates struct {
|
||||
@@ -13,8 +14,12 @@ type Templates struct {
|
||||
func NewTemplates(tmpl *template.Template) *Templates {
|
||||
return &Templates{tmpl: tmpl}
|
||||
}
|
||||
func (t *Templates) Render(w io.Writer, name string, data any) {
|
||||
if err := t.tmpl.ExecuteTemplate(w, name+".html", data); err != nil {
|
||||
func (t *Templates) Render(w http.ResponseWriter, name string, data any) {
|
||||
var buf bytes.Buffer
|
||||
if err := t.tmpl.ExecuteTemplate(&buf, name+".html", data); err != nil {
|
||||
log.Printf("template error: %s: %v", name, err)
|
||||
http.Error(w, "Internal server error", http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
w.Write(buf.Bytes())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user