Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pkg/chassis/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ func (c *Runtime) WithSecretStore(plugin SecretStore) *Runtime {
return c
}

func (c *Runtime) WithClientApplication(files embed.FS) *Runtime {
c.withClientApplication(files)
func (c *Runtime) WithClientApplication(files embed.FS, rootDir string) *Runtime {
c.withClientApplication(files, rootDir)
return c
}

Expand Down
12 changes: 4 additions & 8 deletions pkg/chassis/client_application.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ import (
"strings"
)

const (
webClientRoot = "web-client/dist"
)

// NOTE: the logic for serving a SPA is modified from the example here: https://github.com/gorilla/mux#serving-single-page-applications

// spaHandler implements the http.Handler interface, so we can use it
Expand Down Expand Up @@ -65,21 +61,21 @@ func (h spaHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
http.ServeFileFS(w, r, h.fileSystem, path)
}

func (c *Runtime) withClientApplication(e embed.FS) {
func (c *Runtime) withClientApplication(e embed.FS, rootDir string) {
// Init and store the http multiplexer
if c.mux == nil {
c.mux = http.NewServeMux()
}

spa := spaHandler{
indexPath: "index.html",
fileSystem: c.getFileSystem(e),
fileSystem: c.getFileSystem(e, rootDir),
}
c.mux.Handle("/", spa)
}

func (c *Runtime) getFileSystem(e embed.FS) fs.FS {
fsys, err := fs.Sub(e, webClientRoot)
func (c *Runtime) getFileSystem(e embed.FS, rootDir string) fs.FS {
fsys, err := fs.Sub(e, rootDir)
if err != nil {
panic(err)
}
Expand Down