github.com/cookieai-jar/moby@v17.12.1-ce-rc2+incompatible/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/daemon/cluster"
     6  )
     7  
     8  // networkRouter is a router to talk with the network controller
     9  type networkRouter struct {
    10  	backend Backend
    11  	cluster *cluster.Cluster
    12  	routes  []router.Route
    13  }
    14  
    15  // NewRouter initializes a new network router
    16  func NewRouter(b Backend, c *cluster.Cluster) router.Router {
    17  	r := &networkRouter{
    18  		backend: b,
    19  		cluster: c,
    20  	}
    21  	r.initRoutes()
    22  	return r
    23  }
    24  
    25  // Routes returns the available routes to the network controller
    26  func (r *networkRouter) Routes() []router.Route {
    27  	return r.routes
    28  }
    29  
    30  func (r *networkRouter) initRoutes() {
    31  	r.routes = []router.Route{
    32  		// GET
    33  		router.NewGetRoute("/networks", r.getNetworksList),
    34  		router.NewGetRoute("/networks/", r.getNetworksList),
    35  		router.NewGetRoute("/networks/{id:.+}", r.getNetwork),
    36  		// POST
    37  		router.NewPostRoute("/networks/create", r.postNetworkCreate),
    38  		router.NewPostRoute("/networks/{id:.*}/connect", r.postNetworkConnect),
    39  		router.NewPostRoute("/networks/{id:.*}/disconnect", r.postNetworkDisconnect),
    40  		router.NewPostRoute("/networks/prune", r.postNetworksPrune, router.WithCancel),
    41  		// DELETE
    42  		router.NewDeleteRoute("/networks/{id:.*}", r.deleteNetwork),
    43  	}
    44  }