gohttpserver/internal/handlers/index.go

20 lines
377 B
Go
Raw Normal View History

2022-11-28 03:59:20 +00:00
package handlers
2020-09-30 06:35:07 +00:00
import (
"net/http"
"git.eeqj.de/sneak/gohttpserver/templates"
2020-09-30 06:35:07 +00:00
)
2022-11-28 03:59:20 +00:00
func (s *Handlers) HandleIndex() http.HandlerFunc {
2023-01-29 03:05:02 +00:00
t := templates.GetParsed()
2020-10-29 00:47:37 +00:00
2020-09-30 06:35:07 +00:00
return func(w http.ResponseWriter, r *http.Request) {
2023-01-29 03:05:02 +00:00
err := t.ExecuteTemplate(w, "index.html", nil)
2020-10-28 23:46:22 +00:00
if err != nil {
s.log.Error().Err(err).Msg("")
2020-10-29 00:47:37 +00:00
http.Error(w, http.StatusText(500), 500)
2020-10-28 23:46:22 +00:00
}
2020-09-30 06:35:07 +00:00
}
}