Move frontend

This commit is contained in:
Daniel 2022-09-25 14:07:47 -04:00
parent f89091f3fd
commit a0a6bd1075
4 changed files with 17 additions and 1 deletions

2
.gitmodules vendored
View file

@ -1,3 +1,3 @@
[submodule "frontend"]
path = frontend
path = pkg/frontend/frontend
url = https://github.com/home-assistant/frontend.git

8
pkg/frontend/frontend.go Normal file
View file

@ -0,0 +1,8 @@
package frontend
import (
"embed"
)
//go:embed frontend/hass_frontend
var Root embed.FS

View file

@ -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
}