forked from Mirrors/gomuks
cmd/gomuks: import frontend in main (#475)
This allows using pkg/gomuks as a library without the frontend
This commit is contained in:
parent
bc550cbff4
commit
05fbdaaf0e
3 changed files with 6 additions and 2 deletions
|
@ -30,6 +30,7 @@ import (
|
|||
|
||||
"go.mau.fi/gomuks/pkg/gomuks"
|
||||
"go.mau.fi/gomuks/pkg/hicli"
|
||||
"go.mau.fi/gomuks/web"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -77,6 +78,7 @@ func main() {
|
|||
gmx.Commit = Commit
|
||||
gmx.LinkifiedVersion = LinkifiedVersion
|
||||
gmx.BuildTime = ParsedBuildTime
|
||||
gmx.FrontendFS = web.Frontend
|
||||
gmx.Run()
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ package gomuks
|
|||
|
||||
import (
|
||||
"context"
|
||||
"embed"
|
||||
"fmt"
|
||||
"maps"
|
||||
"net/http"
|
||||
|
@ -55,6 +56,8 @@ type Gomuks struct {
|
|||
TempDir string
|
||||
LogDir string
|
||||
|
||||
FrontendFS embed.FS
|
||||
|
||||
Config Config
|
||||
|
||||
stopOnce sync.Once
|
||||
|
|
|
@ -39,7 +39,6 @@ import (
|
|||
"maunium.net/go/mautrix"
|
||||
|
||||
"go.mau.fi/gomuks/pkg/hicli"
|
||||
"go.mau.fi/gomuks/web"
|
||||
)
|
||||
|
||||
func (gmx *Gomuks) StartServer() {
|
||||
|
@ -62,7 +61,7 @@ func (gmx *Gomuks) StartServer() {
|
|||
router.Handle("/debug/", http.DefaultServeMux)
|
||||
}
|
||||
router.Handle("/_gomuks/", apiHandler)
|
||||
if frontend, err := fs.Sub(web.Frontend, "dist"); err != nil {
|
||||
if frontend, err := fs.Sub(gmx.FrontendFS, "dist"); err != nil {
|
||||
gmx.Log.Warn().Msg("Frontend not found")
|
||||
} else {
|
||||
router.Handle("/", gmx.FrontendCacheMiddleware(http.FileServerFS(frontend)))
|
||||
|
|
Loading…
Add table
Reference in a new issue