github.com/hms58/moby@v1.13.1/api/server/router/plugin/plugin.go (about) 1 package plugin 2 3 import "github.com/docker/docker/api/server/router" 4 5 // pluginRouter is a router to talk with the plugin controller 6 type pluginRouter struct { 7 backend Backend 8 routes []router.Route 9 } 10 11 // NewRouter initializes a new plugin router 12 func NewRouter(b Backend) router.Router { 13 r := &pluginRouter{ 14 backend: b, 15 } 16 r.initRoutes() 17 return r 18 } 19 20 // Routes returns the available routers to the plugin controller 21 func (r *pluginRouter) Routes() []router.Route { 22 return r.routes 23 } 24 25 func (r *pluginRouter) initRoutes() { 26 r.routes = []router.Route{ 27 router.NewGetRoute("/plugins", r.listPlugins), 28 router.NewGetRoute("/plugins/{name:.*}/json", r.inspectPlugin), 29 router.NewGetRoute("/plugins/privileges", r.getPrivileges), 30 router.NewDeleteRoute("/plugins/{name:.*}", r.removePlugin), 31 router.NewPostRoute("/plugins/{name:.*}/enable", r.enablePlugin), // PATCH? 32 router.NewPostRoute("/plugins/{name:.*}/disable", r.disablePlugin), 33 router.Cancellable(router.NewPostRoute("/plugins/pull", r.pullPlugin)), 34 router.Cancellable(router.NewPostRoute("/plugins/{name:.*}/push", r.pushPlugin)), 35 router.Cancellable(router.NewPostRoute("/plugins/{name:.*}/upgrade", r.upgradePlugin)), 36 router.NewPostRoute("/plugins/{name:.*}/set", r.setPlugin), 37 router.NewPostRoute("/plugins/create", r.createPlugin), 38 } 39 }