HoneyComb

HoneyComb is a web interface for managing FreeBSD jails and Bhyve VMs.
Log | Files | Refs | README | LICENSE

main.go (1133B)


      1 /*
      2  * The 'main' program.
      3  */
      4 package main
      5 
      6 import (
      7 	"net/http"
      8 )
      9 
     10 type naming func(num int) string
     11 
     12 func main() {
     13 
     14 	//test := "Tyler"
     15 	test := []string{"Tyler", "Elizabeth", "Allison", "Riven"}
     16 	jail_name := []string{"ca", "test-jail"}
     17 
     18 	http.HandleFunc("/test", func(w http.ResponseWriter, r *http.Request) {
     19 		handler(w, r, test[1])
     20 	})
     21 
     22 	/* Start Jails */
     23 	http.HandleFunc("/start", func(w http.ResponseWriter, r *http.Request) {
     24 		j_start(w, r, jail_name[0])
     25 	})
     26 
     27 	/* Stop Jails */
     28 	http.HandleFunc("/stop", func(w http.ResponseWriter, r *http.Request) {
     29 		j_stop(w, r, jail_name[0])
     30 	})
     31 
     32 	/* Build the UI */
     33 	http.HandleFunc("/buttons", func(w http.ResponseWriter, r *http.Request) {
     34 		for i:=0; i<len(jail_name); i++ {
     35 			render_ui(w, r, jail_name[i])
     36 		}
     37 	})
     38 
     39 	/* 
     40 	 * Commenting this for a test, the below one does work,
     41 	 * but needs improvement
     42 	 *
     43 	 */
     44 	/* Function for rendering the landing page */
     45 	http.Handle("/", http.FileServer(http.Dir("./static")))
     46 
     47 	/* Functions for rendering buttons clicks */
     48 	http.HandleFunc("/status", j_status)
     49 	http.HandleFunc("/hello", helloHandler)
     50 	http.ListenAndServe(":8080", nil)
     51 }