Added go bindata fs to serve web files and added VUE and bootstrap to local files

This commit is contained in:
Nicholas Thompson
2019-02-27 23:26:28 +02:00
committed by ncthompson
parent 8267e71f18
commit 6bd668eb65
11 changed files with 514 additions and 10 deletions

View File

@@ -5,7 +5,9 @@ import (
"log"
"net/http"
"github.com/hpdvanwyk/invertergui/frontend"
"github.com/hpdvanwyk/invertergui/webgui"
"github.com/prometheus/client_golang/prometheus/promhttp"
)
@@ -14,9 +16,14 @@ func main() {
mk2 := NewMk2Mock()
gui := webgui.NewWebGui(mk2)
rootFs := http.FileServer(frontend.BinaryFileSystem("root"))
http.Handle("/", rootFs)
jsFs := http.FileServer(frontend.BinaryFileSystem("js"))
http.Handle("/js/", http.StripPrefix("/js", jsFs))
cssFs := http.FileServer(frontend.BinaryFileSystem("css"))
http.Handle("/css/", http.StripPrefix("/css", cssFs))
http.Handle("/ws", http.HandlerFunc(gui.ServeHub))
http.Handle("/", gui)
http.Handle("/js/controller.js", http.HandlerFunc(gui.ServeJS))
http.Handle("/munin", http.HandlerFunc(gui.ServeMuninHTTP))
http.Handle("/muninconfig", http.HandlerFunc(gui.ServeMuninConfigHTTP))
http.Handle("/metrics", promhttp.Handler())