Esempio n. 1
0
// reloadConfig handles route to "/reloadConfig".
// Reads config/config.json file and redirects to "/monitor".
func reloadConfig(w http.ResponseWriter, r *http.Request) {
	var err error
	cp, err = dmonitor.LoadConfig()

	if err != nil {
		log.Println("Cannot load config file. Check the file at location config/config.json\n", err)
		return
	}

	http.Redirect(w, r, "/monitor", http.StatusFound)
}
Esempio n. 2
0
func main() {
	var err error
	cp, err = dmonitor.LoadConfig()

	if err != nil {
		log.Println("Cannot load config file. Check the file at location config/config.json\n", err)
		return
	}

	http.HandleFunc("/", index)
	http.HandleFunc("/login", login)
	http.HandleFunc("/logout", logout)
	http.HandleFunc("/monitor", monitor)
	http.HandleFunc("/reloadlist", reloadlist)
	http.HandleFunc("/startOrStop", startOrStop)
	// Handler for images.
	http.HandleFunc("/images/", func(w http.ResponseWriter, r *http.Request) {
		http.ServeFile(w, r, r.URL.Path[1:])
	})

	log.Println("Starting dmonitor at port 8008")
	http.ListenAndServe(":8008", nil)
}