Beispiel #1
0
func init() {
	var err error
	Files, err = embed.Unpack(Resources)
	if err != nil {
		panic(err)
	}
}
Beispiel #2
0
func startGUI(addr string, m *model.Model) {
	router := martini.NewRouter()
	router.Get("/", getRoot)
	router.Get("/rest/version", restGetVersion)
	router.Get("/rest/model", restGetModel)
	router.Get("/rest/connections", restGetConnections)
	router.Get("/rest/config", restGetConfig)
	router.Get("/rest/need", restGetNeed)
	router.Get("/rest/system", restGetSystem)

	fs, err := embed.Unpack(Resources)
	if err != nil {
		panic(err)
	}

	go func() {
		mr := martini.New()
		mr.Use(embeddedStatic(fs))
		mr.Use(martini.Recovery())
		mr.Action(router.Handle)
		mr.Map(m)
		err := http.ListenAndServe(addr, mr)
		if err != nil {
			warnln("GUI not possible:", err)
		}
	}()

}
Beispiel #3
0
func RegisterAssets(root string) {
	log.Println("Registering Static Assets...")

	assetMap, _ := embed.Unpack(assets.Assets)

	for asset, value := range assetMap {
		log.Printf("\tRegistering %v\n", asset)
		route := fmt.Sprintf("/%s", asset)

		http.Handle(route, http.HandlerFunc(getHandler(asset, string(value))))
		if asset == root {
			http.Handle("/", http.HandlerFunc(getHandler(asset, string(value))))
			log.Printf("\tRegistered %v to /\n", asset)
		}
		log.Printf("\tRegistered %v to %v\n", asset, route)
	}
}