github.com/ncdc/docker@v0.10.1-0.20160129113957-6c6729ef5b74/api/server/router/volume/volume.go (about)

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