Support HEAD requests

This commit is contained in:
2024-09-24 00:12:41 +02:00
parent da9886ecdd
commit 76aef5d3c0
6 changed files with 33 additions and 23 deletions

View File

@@ -4,6 +4,7 @@ import (
"encoding/base64"
"fmt"
"html/template"
"io"
"net/http"
"net/url"
"os"
@@ -199,12 +200,15 @@ func (tm *TemplateManager) ParseTemplates(silent bool) {
tm.tpl = tpl
}
// Get returns the templates, so they can be used to render views
func (tm *TemplateManager) Get() *template.Template {
// Run runs a template by name
func (tm *TemplateManager) Run(w io.Writer, r *http.Request, name string, data any) (err error) {
if tm.debugModeEnabled {
tm.ParseTemplates(true)
}
return tm.tpl
if r.Method == "HEAD" {
return nil
}
return tm.tpl.ExecuteTemplate(w, name, data)
}
// Template functions. These can be called from within the template to execute