refactor: fix linter errors
This commit is contained in:
19
utils/template.go
Normal file
19
utils/template.go
Normal file
@ -0,0 +1,19 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"github.com/a-h/templ"
|
||||
)
|
||||
|
||||
func RenderTemplate(w http.ResponseWriter, t templ.Component, l *Logger) {
|
||||
if err := t.Render(context.Background(), w); err != nil {
|
||||
l.Error("unable to render template %s", err)
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
_, err := w.Write([]byte{})
|
||||
if err != nil {
|
||||
l.Error(err.Error())
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user