github.com/scorpionis/docker@v1.6.0-rc7/registry/v2/routes.go (about)

     1  package v2
     2  
     3  import "github.com/gorilla/mux"
     4  
     5  // The following are definitions of the name under which all V2 routes are
     6  // registered. These symbols can be used to look up a route based on the name.
     7  const (
     8  	RouteNameBase            = "base"
     9  	RouteNameManifest        = "manifest"
    10  	RouteNameTags            = "tags"
    11  	RouteNameBlob            = "blob"
    12  	RouteNameBlobUpload      = "blob-upload"
    13  	RouteNameBlobUploadChunk = "blob-upload-chunk"
    14  )
    15  
    16  var allEndpoints = []string{
    17  	RouteNameManifest,
    18  	RouteNameTags,
    19  	RouteNameBlob,
    20  	RouteNameBlobUpload,
    21  	RouteNameBlobUploadChunk,
    22  }
    23  
    24  // Router builds a gorilla router with named routes for the various API
    25  // methods. This can be used directly by both server implementations and
    26  // clients.
    27  func Router() *mux.Router {
    28  	router := mux.NewRouter().
    29  		StrictSlash(true)
    30  
    31  	// GET /v2/	Check	Check that the registry implements API version 2(.1)
    32  	router.
    33  		Path("/v2/").
    34  		Name(RouteNameBase)
    35  
    36  	// GET      /v2/<name>/manifest/<reference>	Image Manifest	Fetch the image manifest identified by name and reference where reference can be a tag or digest.
    37  	// PUT      /v2/<name>/manifest/<reference>	Image Manifest	Upload the image manifest identified by name and reference where reference can be a tag or digest.
    38  	// DELETE   /v2/<name>/manifest/<reference>	Image Manifest	Delete the image identified by name and reference where reference can be a tag or digest.
    39  	router.
    40  		Path("/v2/{name:" + RepositoryNameRegexp.String() + "}/manifests/{reference:" + TagNameRegexp.String() + "|" + DigestRegexp.String() + "}").
    41  		Name(RouteNameManifest)
    42  
    43  	// GET	/v2/<name>/tags/list	Tags	Fetch the tags under the repository identified by name.
    44  	router.
    45  		Path("/v2/{name:" + RepositoryNameRegexp.String() + "}/tags/list").
    46  		Name(RouteNameTags)
    47  
    48  	// GET	/v2/<name>/blob/<digest>	Layer	Fetch the blob identified by digest.
    49  	router.
    50  		Path("/v2/{name:" + RepositoryNameRegexp.String() + "}/blobs/{digest:[a-zA-Z0-9-_+.]+:[a-zA-Z0-9-_+.=]+}").
    51  		Name(RouteNameBlob)
    52  
    53  	// POST	/v2/<name>/blob/upload/	Layer Upload	Initiate an upload of the layer identified by tarsum.
    54  	router.
    55  		Path("/v2/{name:" + RepositoryNameRegexp.String() + "}/blobs/uploads/").
    56  		Name(RouteNameBlobUpload)
    57  
    58  	// GET	/v2/<name>/blob/upload/<uuid>	Layer Upload	Get the status of the upload identified by tarsum and uuid.
    59  	// PUT	/v2/<name>/blob/upload/<uuid>	Layer Upload	Upload all or a chunk of the upload identified by tarsum and uuid.
    60  	// DELETE	/v2/<name>/blob/upload/<uuid>	Layer Upload	Cancel the upload identified by layer and uuid
    61  	router.
    62  		Path("/v2/{name:" + RepositoryNameRegexp.String() + "}/blobs/uploads/{uuid}").
    63  		Name(RouteNameBlobUploadChunk)
    64  
    65  	return router
    66  }