diff options
author | Matthew Holt <mholt@users.noreply.github.com> | 2021-09-15 09:55:57 -0600 |
---|---|---|
committer | Matthew Holt <mholt@users.noreply.github.com> | 2021-09-15 09:55:57 -0600 |
commit | 2392478bd3cf3e2878b3fa0eac8859a6374e0fa8 (patch) | |
tree | bb16ac93a6460e3175cb8c205b9ee73bbdd0bb85 /modules/caddyhttp/templates/tplcontext.go | |
parent | a437206643f35a84dea280c99e7e9555fc8df697 (diff) |
templates: Propagate httpError to HTTP response
Now possible with Go 1.17.
See https://github.com/golang/go/issues/34201.
Diffstat (limited to 'modules/caddyhttp/templates/tplcontext.go')
-rw-r--r-- | modules/caddyhttp/templates/tplcontext.go | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/modules/caddyhttp/templates/tplcontext.go b/modules/caddyhttp/templates/tplcontext.go index 1a145a2..14ac31b 100644 --- a/modules/caddyhttp/templates/tplcontext.go +++ b/modules/caddyhttp/templates/tplcontext.go @@ -350,9 +350,8 @@ func (c TemplateContext) funcFileExists(filename string) (bool, error) { return false, nil } -// funcHTTPError returns a structured HTTP handler error. EXPERIMENTAL. -// TODO: Requires https://github.com/golang/go/issues/34201 to be fixed (Go 1.17). -// Example usage might be: `{{if not (fileExists $includeFile)}}{{httpError 404}}{{end}}` +// funcHTTPError returns a structured HTTP handler error. EXPERIMENTAL; SUBJECT TO CHANGE. +// Example usage: `{{if not (fileExists $includeFile)}}{{httpError 404}}{{end}}` func (c TemplateContext) funcHTTPError(statusCode int) (bool, error) { return false, caddyhttp.Error(statusCode, nil) } |