gotelem/openmct.go
saji 8b8619dd8a
All checks were successful
Go / build (1.21) (push) Successful in 1m17s
Go / build (1.22) (push) Successful in 1m15s
added openmct plugin and embedding
2024-03-03 23:04:41 -06:00

30 lines
554 B
Go

//go:build openmct
package gotelem
import (
"embed"
"io/fs"
"net/http"
"github.com/go-chi/chi/v5"
)
// this package provides a web router for the statif openmct build.
// it should only be included if the build has been run,
// to do so, run npm install and then npm run build.
//go:embed web/dist
var public embed.FS
func OpenMCTRouter(r chi.Router) {
// strip the subdirectory
pfs, _ := fs.Sub(public, "web/dist")
// default route.
r.Handle("/*", http.FileServerFS(pfs))
}
func init() {
RouterMods = append(RouterMods, OpenMCTRouter)
}