package frontend import ( "html/template" "net/http" "path/filepath" "strings" ) var dashbaord = template.Must(template.ParseFiles( "frontend/htmx/contents/dash/base.html", "frontend/htmx/contents/dash/dashboard.html")) var home = template.Must(template.ParseFiles("frontend/htmx/home.html")) func Home(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "text/html") err := home.Execute(w, struct { Name string }{ Name: "Miau", }) if err != nil { return } } func Dashboard(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "text/html") err := dashbaord.Execute(w, struct { Title string }{ Title: "Miau", }) if err != nil { return } } func Assets(w http.ResponseWriter, r *http.Request) { path := strings.TrimPrefix(r.URL.Path, "/assets/") http.ServeFile(w, r, filepath.Join("frontend/assets", path)) }