This commit is contained in:
2026-05-06 23:21:43 +02:00
parent 1634c4cc0d
commit def67b14e4
6 changed files with 24 additions and 115 deletions
+8 -3
View File
@@ -3,18 +3,23 @@ package web
import (
"embed"
"io/fs"
"net/http"
)
//go:embed all:dist
var staticFiles embed.FS
// FS returns the embedded frontend/dist subtree.
// Falls back to an empty FS during development (before `make build` runs).
func FS() fs.FS {
sub, err := fs.Sub(staticFiles, "dist")
if err != nil {
return http.FS(http.Dir(""))
// dist not present (pre-build); return an empty FS so the server still starts
return emptyFS{}
}
return sub
}
type emptyFS struct{}
func (emptyFS) Open(name string) (fs.File, error) {
return nil, &fs.PathError{Op: "open", Path: name, Err: fs.ErrNotExist}
}