Add output buffering for rendered pages
This commit is contained in:
parent
65cce5b723
commit
c4c64d0202
1 changed files with 9 additions and 2 deletions
|
@ -18,6 +18,7 @@ limitations under the License.
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"html/template"
|
"html/template"
|
||||||
"io/fs"
|
"io/fs"
|
||||||
|
@ -78,12 +79,18 @@ func (app *application) render(w http.ResponseWriter, status int, page string, d
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
w.WriteHeader(status)
|
buf := new(bytes.Buffer)
|
||||||
|
|
||||||
err := ts.ExecuteTemplate(w, "base", data)
|
err := ts.ExecuteTemplate(buf, "base", data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.serverError(w, err)
|
app.serverError(w, err)
|
||||||
|
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
w.WriteHeader(status)
|
||||||
|
|
||||||
|
_, _ = buf.WriteTo(w)
|
||||||
}
|
}
|
||||||
|
|
||||||
type motionListTemplateData struct {
|
type motionListTemplateData struct {
|
||||||
|
|
Loading…
Reference in a new issue