github.com/Heebron/moby@v0.0.0-20221111184709-6eab4f55faf7/api/server/router/volume/volume.go (about)

     1  package volume // import "github.com/docker/docker/api/server/router/volume"
     2  
     3  import "github.com/docker/docker/api/server/router"
     4  
     5  // volumeRouter is a router to talk with the volumes controller
     6  type volumeRouter struct {
     7  	backend Backend
     8  	cluster ClusterBackend
     9  	routes  []router.Route
    10  }
    11  
    12  // NewRouter initializes a new volume router
    13  func NewRouter(b Backend, cb ClusterBackend) router.Router {
    14  	r := &volumeRouter{
    15  		backend: b,
    16  		cluster: cb,
    17  	}
    18  	r.initRoutes()
    19  	return r
    20  }
    21  
    22  // Routes returns the available routes to the volumes controller
    23  func (r *volumeRouter) Routes() []router.Route {
    24  	return r.routes
    25  }
    26  
    27  func (r *volumeRouter) initRoutes() {
    28  	r.routes = []router.Route{
    29  		// GET
    30  		router.NewGetRoute("/volumes", r.getVolumesList),
    31  		router.NewGetRoute("/volumes/{name:.*}", r.getVolumeByName),
    32  		// POST
    33  		router.NewPostRoute("/volumes/create", r.postVolumesCreate),
    34  		router.NewPostRoute("/volumes/prune", r.postVolumesPrune),
    35  		// PUT
    36  		router.NewPutRoute("/volumes/{name:.*}", r.putVolumesUpdate),
    37  		// DELETE
    38  		router.NewDeleteRoute("/volumes/{name:.*}", r.deleteVolumes),
    39  	}
    40  }