2018-02-05 16:05:59 -05:00
|
|
|
package image // import "github.com/docker/docker/api/server/router/image"
|
2015-12-30 12:20:41 -05:00
|
|
|
|
2016-03-28 14:22:23 -04:00
|
|
|
import (
|
|
|
|
"github.com/docker/docker/api/server/router"
|
|
|
|
)
|
2015-12-30 12:20:41 -05:00
|
|
|
|
|
|
|
// imageRouter is a router to talk with the image controller
|
|
|
|
type imageRouter struct {
|
2016-02-22 13:53:47 -05:00
|
|
|
backend Backend
|
|
|
|
routes []router.Route
|
2015-12-30 12:20:41 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// NewRouter initializes a new image router
|
2018-02-07 15:33:20 -05:00
|
|
|
func NewRouter(backend Backend) router.Router {
|
|
|
|
r := &imageRouter{backend: backend}
|
2015-12-30 12:20:41 -05:00
|
|
|
r.initRoutes()
|
|
|
|
return r
|
|
|
|
}
|
|
|
|
|
|
|
|
// Routes returns the available routes to the image controller
|
|
|
|
func (r *imageRouter) Routes() []router.Route {
|
|
|
|
return r.routes
|
|
|
|
}
|
|
|
|
|
|
|
|
// initRoutes initializes the routes in the image router
|
|
|
|
func (r *imageRouter) initRoutes() {
|
|
|
|
r.routes = []router.Route{
|
|
|
|
// GET
|
|
|
|
router.NewGetRoute("/images/json", r.getImagesJSON),
|
|
|
|
router.NewGetRoute("/images/search", r.getImagesSearch),
|
|
|
|
router.NewGetRoute("/images/get", r.getImagesGet),
|
|
|
|
router.NewGetRoute("/images/{name:.*}/get", r.getImagesGet),
|
|
|
|
router.NewGetRoute("/images/{name:.*}/history", r.getImagesHistory),
|
|
|
|
router.NewGetRoute("/images/{name:.*}/json", r.getImagesByName),
|
|
|
|
// POST
|
|
|
|
router.NewPostRoute("/images/load", r.postImagesLoad),
|
2017-04-10 21:14:36 -04:00
|
|
|
router.NewPostRoute("/images/create", r.postImagesCreate, router.WithCancel),
|
|
|
|
router.NewPostRoute("/images/{name:.*}/push", r.postImagesPush, router.WithCancel),
|
2015-12-30 12:20:41 -05:00
|
|
|
router.NewPostRoute("/images/{name:.*}/tag", r.postImagesTag),
|
2017-04-11 15:52:33 -04:00
|
|
|
router.NewPostRoute("/images/prune", r.postImagesPrune, router.WithCancel),
|
2015-12-30 12:20:41 -05:00
|
|
|
// DELETE
|
|
|
|
router.NewDeleteRoute("/images/{name:.*}", r.deleteImages),
|
|
|
|
}
|
|
|
|
}
|