fix: conditional client build

This commit is contained in:
2025-03-18 14:18:24 -04:00
parent 695e1d94fd
commit 9062609eec
8 changed files with 74 additions and 47 deletions

View File

@ -1,19 +0,0 @@
package handlers
import (
"embed"
"io/fs"
"log"
"net/http"
"github.com/spotdemo4/trevstack/server/internal/interceptors"
)
func NewClientHandler(client embed.FS, key string) http.Handler {
clientFs, err := fs.Sub(client, "client")
if err != nil {
log.Fatalf("failed to get sub filesystem: %v", err)
}
return interceptors.WithAuthRedirect(http.FileServer(http.FS(clientFs)), key)
}

View File

@ -0,0 +1,17 @@
package client
import (
"net/http"
"github.com/spotdemo4/trevstack/server/internal/interceptors"
)
var embedfs *http.FileSystem
func NewClientHandler(key string) http.Handler {
if embedfs != nil {
return interceptors.WithAuthRedirect(http.FileServer(*embedfs), key)
}
return http.NotFoundHandler()
}

View File

@ -0,0 +1,16 @@
// go:build !dev
package client
import (
"embed"
"net/http"
)
//go:embed client
var eclient embed.FS
func init() {
fs := http.FS(eclient)
embedfs = &fs
}