func main() { env.Parse("RS", false) router := mux.NewRouter() router.HandleFunc("/", PrintDoc).Methods("GET") router.HandleFunc("/{node}/{oid}", GetOID).Methods("GET") n := negroni.New( negroni.NewRecovery(), logger.NewLogger(), ) n.UseHandler(router) http.ListenAndServe(config.Listen+":"+config.Port, n) }
func main() { env.Parse("NETMGMT", false) duration, err := strconv.Atoi(config.LockDuration) if err != nil { log.Fatal(err) } locker.Init(duration) f, err := os.Open(config.File) defer f.Close() if err != nil { log.Fatal(err) } b, err := ioutil.ReadAll(f) if err != nil { log.Fatal(err) } networks, err = ReadNetworks(b) if err != nil { log.Fatal(err) } router := mux.NewRouter() router.HandleFunc("/nodes/{node}", GetNodeInfo).Methods("GET") router.HandleFunc("/networks", GetNetworks).Methods("GET") router.HandleFunc("/networks/{net}", GetNetwork).Methods("GET") router.HandleFunc("/networks/{net}/ips", GetNetworkIps).Methods("GET") router.HandleFunc("/networks/{net}", PostReservation).Methods("POST") router.HandleFunc("/conf", GetConfig).Methods("GET") router.HandleFunc("/ui", GetUI).Methods("GET") n := negroni.New( negroni.NewRecovery(), logger.NewLogger(), cors.New(cors.Options{AllowedOrigins: []string{"*"}}), ) n.UseHandler(router) http.ListenAndServe(config.Address+":"+config.Port, n) }