Clearer names for layer upload routes

This commit is contained in:
Stephen J Day 2014-11-10 18:26:06 -08:00
parent 7f75e6368d
commit 0618a2ebd7
2 changed files with 12 additions and 12 deletions

View file

@ -5,21 +5,21 @@ import (
) )
const ( const (
routeNameRoot = "root" routeNameRoot = "root"
routeNameName = "name" routeNameName = "name"
routeNameImageManifest = "image-manifest" routeNameImageManifest = "image-manifest"
routeNameTags = "tags" routeNameTags = "tags"
routeNameLayer = "layer" routeNameLayer = "layer"
routeNameStartLayerUpload = "start-layer-upload" routeNameLayerUpload = "layer-upload"
routeNameLayerUpload = "layer-upload" routeNameLayerUploadResume = "layer-upload-resume"
) )
var allEndpoints = []string{ var allEndpoints = []string{
routeNameImageManifest, routeNameImageManifest,
routeNameTags, routeNameTags,
routeNameLayer, routeNameLayer,
routeNameStartLayerUpload,
routeNameLayerUpload, routeNameLayerUpload,
routeNameLayerUploadResume,
} }
// v2APIRouter builds a gorilla router with named routes for the various API // v2APIRouter builds a gorilla router with named routes for the various API
@ -59,14 +59,14 @@ func v2APIRouter() *mux.Router {
// POST /v2/<name>/layer/<tarsum>/upload/ Layer Upload Initiate an upload of the layer identified by tarsum. Requires length and a checksum parameter. // POST /v2/<name>/layer/<tarsum>/upload/ Layer Upload Initiate an upload of the layer identified by tarsum. Requires length and a checksum parameter.
namedRouter. namedRouter.
Path("/layer/{tarsum}/upload/"). Path("/layer/{tarsum}/upload/").
Name(routeNameStartLayerUpload) Name(routeNameLayerUpload)
// GET /v2/<name>/layer/<tarsum>/upload/<uuid> Layer Upload Get the status of the upload identified by tarsum and uuid. // GET /v2/<name>/layer/<tarsum>/upload/<uuid> Layer Upload Get the status of the upload identified by tarsum and uuid.
// PUT /v2/<name>/layer/<tarsum>/upload/<uuid> Layer Upload Upload all or a chunk of the upload identified by tarsum and uuid. // PUT /v2/<name>/layer/<tarsum>/upload/<uuid> Layer Upload Upload all or a chunk of the upload identified by tarsum and uuid.
// DELETE /v2/<name>/layer/<tarsum>/upload/<uuid> Layer Upload Cancel the upload identified by layer and uuid // DELETE /v2/<name>/layer/<tarsum>/upload/<uuid> Layer Upload Cancel the upload identified by layer and uuid
namedRouter. namedRouter.
Path("/layer/{tarsum}/upload/{uuid}"). Path("/layer/{tarsum}/upload/{uuid}").
Name(routeNameLayerUpload) Name(routeNameLayerUploadResume)
return router return router
} }

View file

@ -76,7 +76,7 @@ func TestRouter(t *testing.T) {
}, },
}, },
{ {
routeName: routeNameStartLayerUpload, routeName: routeNameLayerUpload,
expectedRouteInfo: routeInfo{ expectedRouteInfo: routeInfo{
RequestURI: "/v2/foo/bar/layer/tarsum/upload/", RequestURI: "/v2/foo/bar/layer/tarsum/upload/",
Vars: map[string]string{ Vars: map[string]string{
@ -86,7 +86,7 @@ func TestRouter(t *testing.T) {
}, },
}, },
{ {
routeName: routeNameLayerUpload, routeName: routeNameLayerUploadResume,
expectedRouteInfo: routeInfo{ expectedRouteInfo: routeInfo{
RequestURI: "/v2/foo/bar/layer/tarsum/upload/uuid", RequestURI: "/v2/foo/bar/layer/tarsum/upload/uuid",
Vars: map[string]string{ Vars: map[string]string{