package ui import ( "embed" "io/fs" "net/http" ) //go:embed index.html app.css app.js var files embed.FS func Handler() http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { if r.URL.Path != "/" && r.URL.Path != "/index.html" { http.NotFound(w, r) return } b, err := files.ReadFile("index.html") if err != nil { http.Error(w, err.Error(), 500) return } w.Header().Set("Content-Type", "text/html; charset=utf-8") _, _ = w.Write(b) }) } func Static() http.Handler { sub, err := fs.Sub(files, ".") if err != nil { panic(err) } return http.FileServer(http.FS(sub)) }