github.com/goern/docker@v1.9.0-rc1/api/server/router/network/network.go (about) 1 package network 2 3 import ( 4 "github.com/docker/docker/api/server/router" 5 "github.com/docker/docker/api/server/router/local" 6 "github.com/docker/docker/daemon" 7 ) 8 9 // networkRouter is a router to talk with the network controller 10 type networkRouter struct { 11 daemon *daemon.Daemon 12 routes []router.Route 13 } 14 15 // NewRouter initializes a new network router 16 func NewRouter(d *daemon.Daemon) router.Router { 17 r := &networkRouter{ 18 daemon: d, 19 } 20 r.initRoutes() 21 return r 22 } 23 24 // Routes returns the available routes to the network controller 25 func (r *networkRouter) Routes() []router.Route { 26 return r.routes 27 } 28 29 func (r *networkRouter) initRoutes() { 30 r.routes = []router.Route{ 31 // GET 32 local.NewGetRoute("/networks", r.getNetworksList), 33 local.NewGetRoute("/networks/{id:.*}", r.getNetwork), 34 // POST 35 local.NewPostRoute("/networks/create", r.postNetworkCreate), 36 local.NewPostRoute("/networks/{id:.*}/connect", r.postNetworkConnect), 37 local.NewPostRoute("/networks/{id:.*}/disconnect", r.postNetworkDisconnect), 38 // DELETE 39 local.NewDeleteRoute("/networks/{id:.*}", r.deleteNetwork), 40 } 41 }