Keine Beschreibung

blog.go 725B

    package handlers import ( "html/template" "net/http" ) var ( templateBlog = template.Must(template.ParseFiles( "html/blog.html", "html/directory.html", )) templateArticle = template.Must(template.ParseFiles( "html/blog.html", "html/article.html", )) ) type PageBlog struct { Title string Published string Body template.HTML } func BlogHandler(w http.ResponseWriter, r *http.Request) { if err := templateBlog.Execute(w, nil); err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) } } func BlogArticleHandler(w http.ResponseWriter, r *http.Request) { if err := templateArticle.Execute(w, nil); err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) } }