mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
3976a33c1a
Instead of not adding experimental routes at all, fail with an explicit message if the daemon is not running in experimental mode. Added the `router.Experimental` which does this automatically. Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
36 lines
1.1 KiB
Go
36 lines
1.1 KiB
Go
package checkpoint
|
|
|
|
import (
|
|
"github.com/docker/docker/api/server/httputils"
|
|
"github.com/docker/docker/api/server/router"
|
|
)
|
|
|
|
// checkpointRouter is a router to talk with the checkpoint controller
|
|
type checkpointRouter struct {
|
|
backend Backend
|
|
decoder httputils.ContainerDecoder
|
|
routes []router.Route
|
|
}
|
|
|
|
// NewRouter initializes a new checkpoint router
|
|
func NewRouter(b Backend, decoder httputils.ContainerDecoder) router.Router {
|
|
r := &checkpointRouter{
|
|
backend: b,
|
|
decoder: decoder,
|
|
}
|
|
r.initRoutes()
|
|
return r
|
|
}
|
|
|
|
// Routes returns the available routers to the checkpoint controller
|
|
func (r *checkpointRouter) Routes() []router.Route {
|
|
return r.routes
|
|
}
|
|
|
|
func (r *checkpointRouter) initRoutes() {
|
|
r.routes = []router.Route{
|
|
router.Experimental(router.NewGetRoute("/containers/{name:.*}/checkpoints", r.getContainerCheckpoints)),
|
|
router.Experimental(router.NewPostRoute("/containers/{name:.*}/checkpoints", r.postContainerCheckpoint)),
|
|
router.Experimental(router.NewDeleteRoute("/containers/{name}/checkpoints/{checkpoint}", r.deleteContainerCheckpoint)),
|
|
}
|
|
}
|