summaryrefslogtreecommitdiff
path: root/src/http/tpl.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/http/tpl.go')
-rw-r--r--src/http/tpl.go21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/http/tpl.go b/src/http/tpl.go
index 42341a2..452f444 100644
--- a/src/http/tpl.go
+++ b/src/http/tpl.go
@@ -80,10 +80,12 @@ func (a *api) executeTemplate(
tpl *template.Template,
payload interface{},
) {
-
- tplData := a.newTPLData(r, payload)
-
- buf := new(bytes.Buffer)
+ var (
+ ctx = r.Context()
+ logger = a.params.Logger
+ tplData = a.newTPLData(r, payload)
+ buf = new(bytes.Buffer)
+ )
err := tpl.Execute(buf, tplData)
if errors.Is(err, post.ErrPostNotFound) {
@@ -91,7 +93,7 @@ func (a *api) executeTemplate(
return
} else if err != nil {
apiutil.InternalServerError(
- rw, r, fmt.Errorf("rendering template: %w", err),
+ ctx, logger, rw, "rendering template: %w", err,
)
return
}
@@ -114,12 +116,15 @@ func (a *api) renderDumbTplHandler(tplName string) http.Handler {
tpl := a.mustParseBasedTpl(tplName)
return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
-
- tplData := a.newTPLData(r, nil)
+ var (
+ ctx = r.Context()
+ logger = a.params.Logger
+ tplData = a.newTPLData(r, nil)
+ )
if err := tpl.Execute(rw, tplData); err != nil {
apiutil.InternalServerError(
- rw, r, fmt.Errorf("rendering %q: %w", tplName, err),
+ ctx, logger, rw, "rendering %q: %w", tplName, err,
)
return
}