Skip to content

Commit 08575bc

Browse files
author
novnc
committed
fix: update index template rendering to use buffered output
1 parent 2bb5154 commit 08575bc

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

main.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,14 @@ func init() {
7979
// like the Version string dynamically from the Go build.
8080
indexTmpl = template.Must(template.ParseFiles("./templates/index.html"))
8181
r.GET("/", func(c *gin.Context) {
82-
c.Header("Content-Type", "text/html; charset=utf-8")
8382
data := struct{ Version string }{Version: Version}
84-
if err := indexTmpl.Execute(c.Writer, data); err != nil {
83+
var buf bytes.Buffer
84+
if err := indexTmpl.Execute(&buf, data); err != nil {
8585
log.Printf("failed to render index template: %v", err)
8686
c.String(http.StatusInternalServerError, "Internal Server Error")
8787
return
8888
}
89+
c.Data(http.StatusOK, "text/html; charset=utf-8", buf.Bytes())
8990
})
9091
r.GET("/favicon.ico", func(c *gin.Context) {
9192
c.File("./static/favicon.ico")

0 commit comments

Comments
 (0)