Documentation ¶
Overview ¶
Package hipache provides a router implementation that store routes in Redis, as specified by Hipache (https://github.com/dotcloud/hipache).
It does not provide any exported type, in order to use the router, you must import this package and get the router instance using the function router.Get.
In order to use this router, you need to define the "routers:<name>:type = hipache" or "routers:<name>:type = planb" in your config.
Example ¶
package main import ( "fmt" "net/url" "github.com/tsuru/tsuru/router" _ "github.com/tsuru/tsuru/router/hipache" "github.com/tsuru/tsuru/router/routertest" ) func main() { router, err := router.Get("hipache") if err != nil { panic(err) } err = router.AddBackend(routertest.FakeApp{Name: "myapp"}) if err != nil { panic(err) } u, err := url.Parse("http://10.10.10.10:8080") if err != nil { panic(err) } err = router.AddRoutes("myapp", []*url.URL{u}) if err != nil { panic(err) } addr, _ := router.Addr("myapp") fmt.Println("Please access:", addr) err = router.RemoveRoutes("myapp", []*url.URL{u}) if err != nil { panic(err) } err = router.RemoveBackend("myapp") if err != nil { panic(err) } }
Output:
Click to show internal directories.
Click to hide internal directories.