//go:build prod // +build prod package s3browser import ( "embed" "io/fs" "net/http" "os" ) // content holds our static web server content. //go:embed static var staticFiles embed.FS type spaFileSystem struct { root http.FileSystem } func (spa *spaFileSystem) Open(name string) (http.File, error) { f, err := spa.root.Open(name) if os.IsNotExist(err) { return spa.root.Open("index.html") } return f, err } func initStatic() { staticFS, _ := fs.Sub(staticFiles, "static") http.Handle("/", http.FileServer(&spaFileSystem{http.FS(staticFS)})) }