gohttpserver/internal/handlers/handleindex.go
sneak 75442d261d
Some checks failed
continuous-integration/drone/push Build is failing
this is nowhere near working yet
2022-11-28 04:59:20 +01:00

21 lines
466 B
Go

package handlers
import (
"html/template"
"net/http"
"git.eeqj.de/sneak/gohttpserver/templates"
)
func (s *Handlers) HandleIndex() http.HandlerFunc {
indexTemplate := template.Must(template.New("index").Parse(templates.MustString("index.html")))
return func(w http.ResponseWriter, r *http.Request) {
err := indexTemplate.ExecuteTemplate(w, "index", nil)
if err != nil {
s.log.Println(err.Error())
http.Error(w, http.StatusText(500), 500)
}
}
}