ea1e4aa52d
Replace bindata packages with stdlib go:embed. Modernize some uiserver code with newer interfaces introduced in go 1.16 (mainly working with fs.File instead of http.File. Remove steps that are no longer used from our build files. Add Github Action to detect differences in agent/uiserver/dist and verify that the files are correct (by compiling UI assets and comparing contents).
24 lines
577 B
Go
24 lines
577 B
Go
package uiserver
|
|
|
|
import (
|
|
"io/fs"
|
|
)
|
|
|
|
// redirectFS is an fs.FS that serves the index.html file for any path that is
|
|
// not found on the underlying FS.
|
|
//
|
|
// TODO: it seems better to actually 404 bad paths or at least redirect them
|
|
// rather than pretend index.html is everywhere but this is behavior changing
|
|
// so I don't want to take it on as part of this refactor.
|
|
type redirectFS struct {
|
|
fs fs.FS
|
|
}
|
|
|
|
func (fs *redirectFS) Open(name string) (fs.File, error) {
|
|
file, err := fs.fs.Open(name)
|
|
if err != nil {
|
|
file, err = fs.fs.Open("index.html")
|
|
}
|
|
return file, err
|
|
}
|