github.com/hms58/moby@v1.13.1/api/server/router/image/image.go (about)

     1  package image
     2  
     3  import (
     4  	"github.com/docker/docker/api/server/httputils"
     5  	"github.com/docker/docker/api/server/router"
     6  )
     7  
     8  // imageRouter is a router to talk with the image controller
     9  type imageRouter struct {
    10  	backend Backend
    11  	decoder httputils.ContainerDecoder
    12  	routes  []router.Route
    13  }
    14  
    15  // NewRouter initializes a new image router
    16  func NewRouter(backend Backend, decoder httputils.ContainerDecoder) router.Router {
    17  	r := &imageRouter{
    18  		backend: backend,
    19  		decoder: decoder,
    20  	}
    21  	r.initRoutes()
    22  	return r
    23  }
    24  
    25  // Routes returns the available routes to the image controller
    26  func (r *imageRouter) Routes() []router.Route {
    27  	return r.routes
    28  }
    29  
    30  // initRoutes initializes the routes in the image router
    31  func (r *imageRouter) initRoutes() {
    32  	r.routes = []router.Route{
    33  		// GET
    34  		router.NewGetRoute("/images/json", r.getImagesJSON),
    35  		router.NewGetRoute("/images/search", r.getImagesSearch),
    36  		router.NewGetRoute("/images/get", r.getImagesGet),
    37  		router.NewGetRoute("/images/{name:.*}/get", r.getImagesGet),
    38  		router.NewGetRoute("/images/{name:.*}/history", r.getImagesHistory),
    39  		router.NewGetRoute("/images/{name:.*}/json", r.getImagesByName),
    40  		// POST
    41  		router.NewPostRoute("/commit", r.postCommit),
    42  		router.NewPostRoute("/images/load", r.postImagesLoad),
    43  		router.Cancellable(router.NewPostRoute("/images/create", r.postImagesCreate)),
    44  		router.Cancellable(router.NewPostRoute("/images/{name:.*}/push", r.postImagesPush)),
    45  		router.NewPostRoute("/images/{name:.*}/tag", r.postImagesTag),
    46  		router.NewPostRoute("/images/prune", r.postImagesPrune),
    47  		// DELETE
    48  		router.NewDeleteRoute("/images/{name:.*}", r.deleteImages),
    49  	}
    50  }