2015-12-30 12:20:41 -05:00
|
|
|
package image
|
|
|
|
|
2016-03-28 14:22:23 -04:00
|
|
|
import (
|
|
|
|
"github.com/docker/docker/api/server/httputils"
|
|
|
|
"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
|
2016-03-28 14:22:23 -04:00
|
|
|
decoder httputils.ContainerDecoder
|
2016-02-22 13:53:47 -05:00
|
|
|
routes []router.Route
|
2015-12-30 12:20:41 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// NewRouter initializes a new image router
|
2016-03-28 14:22:23 -04:00
|
|
|
func NewRouter(backend Backend, decoder httputils.ContainerDecoder) router.Router {
|
2015-12-30 12:20:41 -05:00
|
|
|
r := &imageRouter{
|
2016-02-22 13:53:47 -05:00
|
|
|
backend: backend,
|
2016-03-28 14:22:23 -04:00
|
|
|
decoder: decoder,
|
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("/commit", r.postCommit),
|
|
|
|
router.NewPostRoute("/images/load", r.postImagesLoad),
|
2016-03-28 00:53:25 -04:00
|
|
|
router.Cancellable(router.NewPostRoute("/images/create", r.postImagesCreate)),
|
|
|
|
router.Cancellable(router.NewPostRoute("/images/{name:.*}/push", r.postImagesPush)),
|
2015-12-30 12:20:41 -05:00
|
|
|
router.NewPostRoute("/images/{name:.*}/tag", r.postImagesTag),
|
|
|
|
// DELETE
|
|
|
|
router.NewDeleteRoute("/images/{name:.*}", r.deleteImages),
|
|
|
|
}
|
|
|
|
}
|