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),
|
2018-11-27 17:13:43 -05:00
|
|
|
router.NewPostRoute("/images/create", r.postImagesCreate),
|
|
|
|
router.NewPostRoute("/images/{name:.*}/push", r.postImagesPush),
|
2015-12-30 12:20:41 -05:00
|
|
|
router.NewPostRoute("/images/{name:.*}/tag", r.postImagesTag),
|
2018-11-27 17:13:43 -05:00
|
|
|
router.NewPostRoute("/images/prune", r.postImagesPrune),
|
2015-12-30 12:20:41 -05:00
|
|
|
// DELETE
|
|
|
|
router.NewDeleteRoute("/images/{name:.*}", r.deleteImages),
|
|
|
|
}
|
|
|
|
}
|