...

Source file src/github.com/docker/distribution/registry/api/v2/routes.go

Documentation: github.com/docker/distribution/registry/api/v2

     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  	RouteNameCatalog         = "catalog"
    15  )
    16  
    17  // Router builds a gorilla router with named routes for the various API
    18  // methods. This can be used directly by both server implementations and
    19  // clients.
    20  func Router() *mux.Router {
    21  	return RouterWithPrefix("")
    22  }
    23  
    24  // RouterWithPrefix builds a gorilla router with a configured prefix
    25  // on all routes.
    26  func RouterWithPrefix(prefix string) *mux.Router {
    27  	rootRouter := mux.NewRouter()
    28  	router := rootRouter
    29  	if prefix != "" {
    30  		router = router.PathPrefix(prefix).Subrouter()
    31  	}
    32  
    33  	router.StrictSlash(true)
    34  
    35  	for _, descriptor := range routeDescriptors {
    36  		router.Path(descriptor.Path).Name(descriptor.Name)
    37  	}
    38  
    39  	return rootRouter
    40  }
    41  

View as plain text