zdravko/internal/pages/index.go

25 lines
486 B
Go
Raw Normal View History

package pages
import (
"net/http"
"text/template"
2024-02-11 10:56:21 +00:00
"code.tjo.space/mentos1386/zdravko/internal/ui"
)
2024-02-11 10:56:21 +00:00
func (p *PageHandler) Index(w http.ResponseWriter, r *http.Request) {
ts, err := template.ParseFS(ui.Templates,
"components/base.tmpl",
"pages/index.tmpl",
)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
err = ts.ExecuteTemplate(w, "base", nil)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
}
}