in pkg/containerd/handler.go [30:80]
func (r *Registry) Handle(c pcontext.Context) {
dgstStr := c.GetString(pcontext.DigestCtxKey)
ref := c.GetString(pcontext.ReferenceCtxKey)
var d digest.Digest
var err error
l := pcontext.Logger(c).With().Str("handler", "registry").Str("ref", ref).Str("digest", dgstStr).Logger()
l.Debug().Msg("registry handler start")
s := time.Now()
defer func() {
l.Debug().Dur("duration", time.Since(s)).Int("status", c.Writer.Status()).Str("digest", d.String()).Msg("registry handler stop")
}()
// Serve registry endpoints.
if dgstStr == "" {
d, err = r.containerdStore.Resolve(c, ref)
if err != nil {
//nolint
c.AbortWithError(http.StatusNotFound, err)
return
}
} else {
d, err = digest.Parse(dgstStr)
if err != nil {
//nolint
c.AbortWithError(http.StatusBadRequest, err)
return
}
}
refType, ok := c.Get(pcontext.RefTypeCtxKey)
if !ok {
//nolint
c.AbortWithError(http.StatusInternalServerError, fmt.Errorf("ref type not found in context"))
return
}
switch refType.(distribution.ReferenceType) {
case distribution.ReferenceTypeManifest:
r.handleManifest(c, d)
return
case distribution.ReferenceTypeBlob:
r.handleBlob(c, d)
return
}
// If nothing matches return 404.
c.Status(http.StatusNotFound)
}