2022-11-28 00:19:47 +00:00
|
|
|
package server
|
2020-09-30 06:35:07 +00:00
|
|
|
|
|
|
|
import (
|
2020-10-29 00:47:37 +00:00
|
|
|
"html/template"
|
|
|
|
"log"
|
2020-09-30 06:35:07 +00:00
|
|
|
"net/http"
|
2022-11-28 00:19:47 +00:00
|
|
|
|
|
|
|
"git.eeqj.de/sneak/gohttpserver/templates"
|
2020-09-30 06:35:07 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func (s *server) handleIndex() http.HandlerFunc {
|
2022-11-28 00:19:47 +00:00
|
|
|
indexTemplate := template.Must(template.New("index").Parse(templates.MustString("index.html")))
|
2020-10-29 00:47:37 +00:00
|
|
|
|
2020-09-30 06:35:07 +00:00
|
|
|
return func(w http.ResponseWriter, r *http.Request) {
|
2020-10-29 00:47:37 +00:00
|
|
|
err := indexTemplate.ExecuteTemplate(w, "index", nil)
|
2020-10-28 23:46:22 +00:00
|
|
|
if err != nil {
|
2020-10-29 00:47:37 +00:00
|
|
|
log.Println(err.Error())
|
|
|
|
http.Error(w, http.StatusText(500), 500)
|
2020-10-28 23:46:22 +00:00
|
|
|
}
|
2020-09-30 06:35:07 +00:00
|
|
|
}
|
|
|
|
}
|