Beispiel #1
0
func Example() {
	router, err := router.Get("hipache")
	if err != nil {
		panic(err)
	}
	err = router.AddBackend("myapp")
	if err != nil {
		panic(err)
	}
	url, err := url.Parse("http://10.10.10.10:8080")
	if err != nil {
		panic(err)
	}
	err = router.AddRoute("myapp", url)
	if err != nil {
		panic(err)
	}
	addr, _ := router.Addr("myapp")
	fmt.Println("Please access:", addr)
	err = router.RemoveRoute("myapp", url)
	if err != nil {
		panic(err)
	}
	err = router.RemoveBackend("myapp")
	if err != nil {
		panic(err)
	}
}
Beispiel #2
0
func (p *JujuProvisioner) Addr(app provision.App) (string, error) {
	if p.elbSupport() {
		router, err := Router()
		if err != nil {
			return "", err
		}
		addr, err := router.Addr(app.GetName())
		if err != nil {
			return "", fmt.Errorf("There is no ACTIVE Load Balancer named %s", app.GetName())
		}
		return addr, nil
	}
	units := app.ProvisionedUnits()
	if len(units) < 1 {
		return "", fmt.Errorf("App %q has no units.", app.GetName())
	}
	return units[0].GetIp(), nil
}