summaryrefslogtreecommitdiff
path: root/cmd/generate/templates.go.tmpl
diff options
context:
space:
mode:
authorMathias Magnusson <mathias@magnusson.space>2026-01-24 01:57:33 +0100
committerMathias Magnusson <mathias@magnusson.space>2026-01-24 01:57:33 +0100
commit39c6170ccab2977bbbaecdde2fdff772f39e2415 (patch)
tree97d1d360e8ce62517a573380c0c03362915e55e8 /cmd/generate/templates.go.tmpl
parent1fe804770391a644e23eea7c22e0868e3dfb4d2e (diff)
downloadhh-main.tar.gz
allow returning values from handlersHEADmain
Diffstat (limited to 'cmd/generate/templates.go.tmpl')
-rw-r--r--cmd/generate/templates.go.tmpl24
1 files changed, 23 insertions, 1 deletions
diff --git a/cmd/generate/templates.go.tmpl b/cmd/generate/templates.go.tmpl
index 3533b2b..9ee259b 100644
--- a/cmd/generate/templates.go.tmpl
+++ b/cmd/generate/templates.go.tmpl
@@ -66,6 +66,28 @@ func hh_{{ $fn.Name }}(w http.ResponseWriter, r *http.Request) {
}
}
{{ end }}
- {{ $fn.Name }}(parsed)
+ {{ if $fn.ResponseHasMain -}}
+ res
+ {{- end -}}
+ {{- if and $fn.ResponseHasMain $fn.ResponseHasError -}}
+ ,
+ {{- end -}}
+ {{- if $fn.ResponseHasError -}}
+ err
+ {{- end -}}
+ {{- if or $fn.ResponseHasMain $fn.ResponseHasError -}}
+ :=
+ {{- end -}}
+ {{- $fn.Name }}(parsed)
+
+ {{ if $fn.ResponseHasError }}
+ if err != nil {
+ panic("todo: Internal server error in " + {{ $fn.Name | quote }} + ": " + err.Error())
+ // return
+ }
+ {{ end }}
+ {{ if $fn.ResponseHasMain -}}
+ res.Respond(w, r)
+ {{- end -}}
}
{{ end }}