Example #1
0
// gets routing table from configuration
func get_routes() (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, fmt.Errorf("bad configuration : proxy_table should be map[string][]string")
	}
	return addrs, nil
}
Example #2
0
func main() {
	flag.Parse()
	if err := conf.LoadConfig(*conf_path); err != nil {
		log.Fatalln("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
	}
	if err = http.ListenAndServe(address, nil); err != nil {
		log.Fatalln(err)
	}
}