Bump version to 1.0.3
webui: use fs.Sub to fix embed FS root so static assets are found Previously http.FileServer searched for assets/foo.css in the embed FS rooted at dist/, but only paths starting with dist/ resolve. fs.Sub strips the dist/ prefix so FileServer finds the actual files.
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
BINARY=syncserver
|
BINARY=syncserver
|
||||||
VERSION?=1.0.2
|
VERSION?=1.0.3
|
||||||
GO?=go
|
GO?=go
|
||||||
LDFLAGS=-s -w -X main.version=$(VERSION) -X main.commit=$(shell git rev-parse --short HEAD 2>/dev/null || echo unknown)
|
LDFLAGS=-s -w -X main.version=$(VERSION) -X main.commit=$(shell git rev-parse --short HEAD 2>/dev/null || echo unknown)
|
||||||
BUILD_FLAGS=CGO_ENABLED=0
|
BUILD_FLAGS=CGO_ENABLED=0
|
||||||
|
|||||||
+1
-1
@@ -20,7 +20,7 @@ import (
|
|||||||
"github.com/syncserver/internal/syncengine"
|
"github.com/syncserver/internal/syncengine"
|
||||||
)
|
)
|
||||||
|
|
||||||
var version = "1.0.2"
|
var version = "1.0.3"
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
cfgPath := flag.String("config", "", "Path to config.yaml")
|
cfgPath := flag.String("config", "", "Path to config.yaml")
|
||||||
|
|||||||
@@ -9,15 +9,19 @@ import (
|
|||||||
//go:embed dist
|
//go:embed dist
|
||||||
var DistFS embed.FS
|
var DistFS embed.FS
|
||||||
|
|
||||||
var Dist fs.FS = DistFS
|
var distSub, _ = fs.Sub(DistFS, "dist")
|
||||||
|
|
||||||
func ServeHTTP() http.Handler {
|
func ServeHTTP() http.Handler {
|
||||||
return http.FileServer(http.FS(DistFS))
|
return http.FileServer(http.FS(distSub))
|
||||||
}
|
}
|
||||||
|
|
||||||
func ServeSPA() http.Handler {
|
func ServeSPA() http.Handler {
|
||||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
path := r.URL.Path
|
path := r.URL.Path
|
||||||
|
if path == "/favicon.ico" {
|
||||||
|
w.WriteHeader(http.StatusNoContent)
|
||||||
|
return
|
||||||
|
}
|
||||||
if path == "/" || !isStaticAsset(path) {
|
if path == "/" || !isStaticAsset(path) {
|
||||||
data, err := DistFS.ReadFile("dist/index.html")
|
data, err := DistFS.ReadFile("dist/index.html")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -28,7 +32,7 @@ func ServeSPA() http.Handler {
|
|||||||
w.Write(data)
|
w.Write(data)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
http.StripPrefix("/", http.FileServer(http.FS(DistFS))).ServeHTTP(w, r)
|
http.FileServer(http.FS(distSub)).ServeHTTP(w, r)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user