package webapp import ( "embed" "io/fs" "net/http" "os" ) //go:embed dist var embeddedWebappFS embed.FS // GetFilesystem returns a HTTP filesystem with the embedded webapp files func GetFilesystem() (http.FileSystem, error) { // Try embedded filesystem first (production mode) if embeddedFS, err := fs.Sub(embeddedWebappFS, "dist"); err == nil { // Check if embedded filesystem has content by trying to open index.html if _, err := embeddedFS.Open("index.html"); err == nil { return http.FS(embeddedFS), nil } } // Fallback to filesystem for development (when dist exists locally) if _, err := os.Stat("dist"); err == nil { return http.Dir("dist"), nil } // Fall back to an empty filesystem if files don't exist return http.Dir("."), nil }