diff --git a/.gitmodules b/.gitmodules index 31c5452..7941c82 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "frontend"] - path = frontend + path = pkg/frontend/frontend url = https://github.com/home-assistant/frontend.git diff --git a/frontend b/pkg/frontend/frontend similarity index 100% rename from frontend rename to pkg/frontend/frontend diff --git a/pkg/frontend/frontend.go b/pkg/frontend/frontend.go new file mode 100644 index 0000000..d6b40a8 --- /dev/null +++ b/pkg/frontend/frontend.go @@ -0,0 +1,8 @@ +package frontend + +import ( + "embed" +) + +//go:embed frontend/hass_frontend +var Root embed.FS diff --git a/pkg/server/server.go b/pkg/server/server.go index 6f96dc5..0660d91 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -1,12 +1,14 @@ package server import ( + "io/fs" "log" "net/http" "sync" "dynatron.me/x/blasphem/pkg/bus" "dynatron.me/x/blasphem/pkg/config" + "dynatron.me/x/blasphem/pkg/frontend" ) type Server struct { @@ -28,7 +30,13 @@ func New(cfg *config.Config) (*Server, error) { cfg: cfg, } + rootFS, err := fs.Sub(frontend.Root, "frontend/hass_frontend") + if err != nil { + return nil, err + } + mux.HandleFunc("/api/websocket", s.wsHandler) + mux.Handle("/", http.FileServer(http.FS(rootFS))) return s, nil }