package main import ( "log" "net/http" "text/template" ) type server struct { template *template.Template } func main() { t := template.Must(template.ParseFiles("templates/index.html")) s := server{template: t} http.HandleFunc("/", s.handleRoot) http.Handle("/resources/", http.FileServer(http.Dir("."))) log.Println("Listening on http://localhost:8080") err := http.ListenAndServe(":8080", nil) log.Fatal(err) } func (s *server) handleRoot(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "text/html; charset=utf8") if r.RequestURI != "/" { http.NotFound(w, r) return } err := s.template.Execute(w, "Vrolijk pasen!") if err != nil { log.Println(err) } }