package handler import ( "github.com/loveuer/nf" "github.com/sirupsen/logrus" "nf-repo/internal/interfaces" "nf-repo/internal/opt" "nf-repo/internal/util/rerr" ) type blob struct { blobHandler interfaces.BlobHandler uploadHandler interfaces.UploadHandler } var ( b = &blob{} ) func Root(bh interfaces.BlobHandler, uh interfaces.UploadHandler, mh interfaces.ManifestHandler) nf.HandlerFunc { b.blobHandler = bh b.uploadHandler = uh return func(c *nf.Ctx) error { if isBlob(c) { return handleBlobs(c) } if isManifest(c) { return handleManifest(c, mh) } if isTags(c) { return handleTags(c, mh) } if isCatalog(c) { return handleCatalog(c, mh) } if opt.ReferrersEnabled && isReferrers(c) { return handleReferrers(c, mh) } c.SetHeader("Docker-Distribution-API-Version", "registry/2.0") logrus. WithField("path", c.Path()). WithField("method", c.Method()). WithField("headers", c.Request.Header). Warn() return rerr.Error(c, rerr.ErrUnauthorized) } }