Example #1
0
func main() {
	flag.Parse()
	docker, _ = dockerclient.NewDockerClient("unix:///var/run/docker.sock", nil)
	kong = kongo.NewKong(kongUrl)

	endpoints, err := kong.GetEndpoints()
	if err != nil {
		panic(err)
	}
	for _, endpoint := range endpoints {
		log.Printf("%s => %s\n", endpoint.Path, endpoint.TargetUrl)
	}

	// Get running containers
	containers, err := docker.ListContainers(false, false, "")
	if err != nil {
		log.Fatal(err)
	}

	for _, c := range containers {
		checkAndSync(c.Id)
	}

	// Listen to events
	docker.StartMonitorEvents(eventCallback, nil)

	// Hold the execution to look at the events coming
	for true {
		time.Sleep(3600 * time.Second)
		log.Println("PONG")
	}
}
Example #2
0
func main() {
	kong := kongo.NewKong("http://localhost:8001")
	endpoints, err := kong.GetEndpoints()
	if err != nil {
		panic(err)
	}

	for _, endpoint := range endpoints {
		log.Println(endpoint.Name, "(", endpoint.Path, ")", "=>", endpoint.TargetUrl)
		plugins, err := kong.GetPlugins(endpoint.Name)
		if err != nil {
			panic(err)
		}
		for _, plugin := range plugins {
			log.Printf("\t%s %t %#v\n", plugin.Name, plugin.Value)
		}
	}
}