mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
534a90a993
As described in our ROADMAP.md, introduce new Swarm management API endpoints relying on swarmkit to deploy services. It currently vendors docker/engine-api changes. This PR is fully backward compatible (joining a Swarm is an optional feature of the Engine, and existing commands are not impacted). Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com> Signed-off-by: Victor Vieux <vieux@docker.com> Signed-off-by: Daniel Nephin <dnephin@docker.com> Signed-off-by: Jana Radhakrishnan <mrjana@docker.com> Signed-off-by: Madhu Venugopal <madhu@docker.com>
42 lines
1.1 KiB
Go
42 lines
1.1 KiB
Go
package network
|
|
|
|
import (
|
|
"github.com/docker/docker/api/server/router"
|
|
"github.com/docker/docker/daemon/cluster"
|
|
)
|
|
|
|
// networkRouter is a router to talk with the network controller
|
|
type networkRouter struct {
|
|
backend Backend
|
|
clusterProvider *cluster.Cluster
|
|
routes []router.Route
|
|
}
|
|
|
|
// NewRouter initializes a new network router
|
|
func NewRouter(b Backend, c *cluster.Cluster) router.Router {
|
|
r := &networkRouter{
|
|
backend: b,
|
|
clusterProvider: c,
|
|
}
|
|
r.initRoutes()
|
|
return r
|
|
}
|
|
|
|
// Routes returns the available routes to the network controller
|
|
func (r *networkRouter) Routes() []router.Route {
|
|
return r.routes
|
|
}
|
|
|
|
func (r *networkRouter) initRoutes() {
|
|
r.routes = []router.Route{
|
|
// GET
|
|
router.NewGetRoute("/networks", r.getNetworksList),
|
|
router.NewGetRoute("/networks/{id:.*}", r.getNetwork),
|
|
// POST
|
|
router.NewPostRoute("/networks/create", r.postNetworkCreate),
|
|
router.NewPostRoute("/networks/{id:.*}/connect", r.postNetworkConnect),
|
|
router.NewPostRoute("/networks/{id:.*}/disconnect", r.postNetworkDisconnect),
|
|
// DELETE
|
|
router.NewDeleteRoute("/networks/{id:.*}", r.deleteNetwork),
|
|
}
|
|
}
|