idk
This commit is contained in:
+8
-3
@@ -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}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user