Skip to content

Commit

Permalink
move web package to cmd/gomuks
Browse files Browse the repository at this point in the history
makes using the library without the web bits easier
  • Loading branch information
batuhan committed Nov 10, 2024
1 parent bc550cb commit 37608d9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions cmd/gomuks/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (

"go.mau.fi/gomuks/pkg/gomuks"
"go.mau.fi/gomuks/pkg/hicli"
"go.mau.fi/gomuks/web"
)

var (
Expand Down Expand Up @@ -77,6 +78,7 @@ func main() {
gmx.Commit = Commit
gmx.LinkifiedVersion = LinkifiedVersion
gmx.BuildTime = ParsedBuildTime
gmx.FrontendFS = web.Frontend
gmx.Run()
}

Expand Down
3 changes: 3 additions & 0 deletions pkg/gomuks/gomuks.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package gomuks

import (
"context"
"embed"
"fmt"
"maps"
"net/http"
Expand Down Expand Up @@ -55,6 +56,8 @@ type Gomuks struct {
TempDir string
LogDir string

FrontendFS embed.FS

Config Config

stopOnce sync.Once
Expand Down
3 changes: 1 addition & 2 deletions pkg/gomuks/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ import (
"maunium.net/go/mautrix"

"go.mau.fi/gomuks/pkg/hicli"
"go.mau.fi/gomuks/web"
)

func (gmx *Gomuks) StartServer() {
Expand All @@ -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)))
Expand Down

0 comments on commit 37608d9

Please sign in to comment.