mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
05390c4f6e
The cancellable handler is no longer needed as the context that is passed with the http request will be cancelled just like the close notifier was doing. Signed-off-by: Brian Goff <cpuguy83@gmail.com>
43 lines
1.2 KiB
Go
43 lines
1.2 KiB
Go
package network // import "github.com/docker/docker/api/server/router/network"
|
|
|
|
import (
|
|
"github.com/docker/docker/api/server/router"
|
|
)
|
|
|
|
// networkRouter is a router to talk with the network controller
|
|
type networkRouter struct {
|
|
backend Backend
|
|
cluster ClusterBackend
|
|
routes []router.Route
|
|
}
|
|
|
|
// NewRouter initializes a new network router
|
|
func NewRouter(b Backend, c ClusterBackend) router.Router {
|
|
r := &networkRouter{
|
|
backend: b,
|
|
cluster: 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/", 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),
|
|
router.NewPostRoute("/networks/prune", r.postNetworksPrune),
|
|
// DELETE
|
|
router.NewDeleteRoute("/networks/{id:.*}", r.deleteNetwork),
|
|
}
|
|
}
|