2015-10-27 15:06:35 -04:00
|
|
|
package volume
|
|
|
|
|
2015-12-30 12:20:41 -05:00
|
|
|
import "github.com/docker/docker/api/server/router"
|
2015-10-27 15:06:35 -04:00
|
|
|
|
2015-11-07 23:05:59 -05:00
|
|
|
// volumeRouter is a router to talk with the volumes controller
|
2015-10-27 15:06:35 -04:00
|
|
|
type volumeRouter struct {
|
2015-11-02 19:26:45 -05:00
|
|
|
backend Backend
|
|
|
|
routes []router.Route
|
2015-10-27 15:06:35 -04:00
|
|
|
}
|
|
|
|
|
2015-12-30 12:20:41 -05:00
|
|
|
// NewRouter initializes a new volume router
|
2015-11-02 19:26:45 -05:00
|
|
|
func NewRouter(b Backend) router.Router {
|
2015-10-27 15:06:35 -04:00
|
|
|
r := &volumeRouter{
|
2015-11-02 19:26:45 -05:00
|
|
|
backend: b,
|
2015-10-27 15:06:35 -04:00
|
|
|
}
|
|
|
|
r.initRoutes()
|
|
|
|
return r
|
|
|
|
}
|
|
|
|
|
2015-12-30 12:20:41 -05:00
|
|
|
// Routes returns the available routes to the volumes controller
|
2015-10-27 15:06:35 -04:00
|
|
|
func (r *volumeRouter) Routes() []router.Route {
|
|
|
|
return r.routes
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *volumeRouter) initRoutes() {
|
|
|
|
r.routes = []router.Route{
|
|
|
|
// GET
|
2015-12-30 12:20:41 -05:00
|
|
|
router.NewGetRoute("/volumes", r.getVolumesList),
|
|
|
|
router.NewGetRoute("/volumes/{name:.*}", r.getVolumeByName),
|
2015-10-27 15:06:35 -04:00
|
|
|
// POST
|
2015-12-30 12:20:41 -05:00
|
|
|
router.NewPostRoute("/volumes/create", r.postVolumesCreate),
|
2017-04-11 15:52:33 -04:00
|
|
|
router.NewPostRoute("/volumes/prune", r.postVolumesPrune, router.WithCancel),
|
2015-10-27 15:06:35 -04:00
|
|
|
// DELETE
|
2015-12-30 12:20:41 -05:00
|
|
|
router.NewDeleteRoute("/volumes/{name:.*}", r.deleteVolumes),
|
2015-10-27 15:06:35 -04:00
|
|
|
}
|
|
|
|
}
|