func getRoutingTable() (map[string]interface{}, error) { tmp, err := conf.Get("proxy_table") if err != nil { return nil, err } addrs, ok := tmp.(map[string]interface{}) if !ok { return nil, errors.New("bad configuration : proxy_table should be map[string][]string") } return addrs, nil }
func main() { flag.Parse() if err := conf.LoadConfig(*conf_path); err != nil { log.Fatal("could not read configuration file :", err) } addr, err := conf.Get("addr") if err != nil { log.Println("addr parameter not specified, using default -", def_addr) addr = def_addr } address, ok := addr.(string) if !ok { log.Println("invalid addr parameter specified, using default -", def_addr) address = def_addr } http.Handle("/challenges/", &httputil.ReverseProxy{Director: proxyDirector}) http.HandleFunc("/", mainHandler) http.Handle("/notfound", http.NotFoundHandler()) if err = http.ListenAndServe(address, nil); err != nil { log.Fatalln(err) } }