This is my boilerplate for a Go http server project. Feedback and suggestions are encouraged!
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
gohttpserver/httpserver/handleindex.go

19 lines
432 B

package httpserver
import (
"html/template"
"log"
"net/http"
)
func (s *server) handleIndex() http.HandlerFunc {
indexTemplate := template.Must(template.New("index").Parse(s.templateFiles.MustString("index.html")))
return func(w http.ResponseWriter, r *http.Request) {
err := indexTemplate.ExecuteTemplate(w, "index", nil)
if err != nil {
log.Println(err.Error())
http.Error(w, http.StatusText(500), 500)
}
}
}