25 lines
617 B
Go
25 lines
617 B
Go
package handlers
|
|
|
|
import (
|
|
"html/template"
|
|
"log/slog"
|
|
"net/http"
|
|
|
|
"git.clustercockpit.org/moebiusband/go-http-skeleton/web"
|
|
)
|
|
|
|
func RootHandler() http.HandlerFunc {
|
|
return func(w http.ResponseWriter, r *http.Request) {
|
|
slog.Info("Render root handler")
|
|
tpl := template.Must(template.ParseFS(web.Templates, "templates/index.html", "templates/base.html"))
|
|
|
|
data := web.PageData{
|
|
Title: "DyeForYarn",
|
|
}
|
|
if err := tpl.ExecuteTemplate(w, "base", data); err != nil {
|
|
http.Error(w, "Internal Server Error", http.StatusInternalServerError)
|
|
slog.Error("Error executing template", "error", err)
|
|
}
|
|
}
|
|
}
|