Add: embed web files

This commit is contained in:
2022-12-17 15:55:10 +08:00
parent d52c64d25a
commit 21b2098c78
3 changed files with 19 additions and 3 deletions

View File

@@ -1,11 +1,12 @@
package api
import (
"github.com/gorilla/sessions"
"msw-open-music/pkg/commonconfig"
"msw-open-music/pkg/database"
"msw-open-music/pkg/tmpfs"
"net/http"
"github.com/gorilla/sessions"
)
type API struct {
@@ -103,7 +104,7 @@ func NewAPI(config commonconfig.Config) (*API, error) {
apiMux.HandleFunc("/reset", api.HandleReset)
mux.Handle("/api/v1/", http.StripPrefix("/api/v1", api.PermissionMiddleware(apiMux)))
mux.Handle("/", http.StripPrefix("/", http.FileServer(http.Dir("web/build"))))
mux.Handle("/", http.StripPrefix("/", http.FileServer(http.FS(config.WEBFS))))
return api, nil
}