https://github.com/opencontainers/distribution-spec/blob/master/spec.md#pulling-an-image-manifest https://github.com/opencontainers/distribution-spec/blob/master/spec.md#pushing-an-image
(resp http.ResponseWriter, req *http.Request)
| 92 | // https://github.com/opencontainers/distribution-spec/blob/master/spec.md#pulling-an-image-manifest |
| 93 | // https://github.com/opencontainers/distribution-spec/blob/master/spec.md#pushing-an-image |
| 94 | func (m *manifests) handle(resp http.ResponseWriter, req *http.Request) *regError { |
| 95 | elem := strings.Split(req.URL.Path, "/") |
| 96 | elem = elem[1:] |
| 97 | target := elem[len(elem)-1] |
| 98 | repo := strings.Join(elem[1:len(elem)-2], "/") |
| 99 | |
| 100 | switch req.Method { |
| 101 | case http.MethodGet: |
| 102 | m.lock.RLock() |
| 103 | defer m.lock.RUnlock() |
| 104 | |
| 105 | c, ok := m.manifests[repo] |
| 106 | if !ok { |
| 107 | return ®Error{ |
| 108 | Status: http.StatusNotFound, |
| 109 | Code: "NAME_UNKNOWN", |
| 110 | Message: "Unknown name", |
| 111 | } |
| 112 | } |
| 113 | m, ok := c[target] |
| 114 | if !ok { |
| 115 | return ®Error{ |
| 116 | Status: http.StatusNotFound, |
| 117 | Code: "MANIFEST_UNKNOWN", |
| 118 | Message: "Unknown manifest", |
| 119 | } |
| 120 | } |
| 121 | |
| 122 | h, _, _ := v1.SHA256(bytes.NewReader(m.blob)) |
| 123 | resp.Header().Set("Docker-Content-Digest", h.String()) |
| 124 | resp.Header().Set("Content-Type", m.contentType) |
| 125 | resp.Header().Set("Content-Length", fmt.Sprint(len(m.blob))) |
| 126 | resp.WriteHeader(http.StatusOK) |
| 127 | io.Copy(resp, bytes.NewReader(m.blob)) |
| 128 | return nil |
| 129 | |
| 130 | case http.MethodHead: |
| 131 | m.lock.RLock() |
| 132 | defer m.lock.RUnlock() |
| 133 | |
| 134 | if _, ok := m.manifests[repo]; !ok { |
| 135 | return ®Error{ |
| 136 | Status: http.StatusNotFound, |
| 137 | Code: "NAME_UNKNOWN", |
| 138 | Message: "Unknown name", |
| 139 | } |
| 140 | } |
| 141 | m, ok := m.manifests[repo][target] |
| 142 | if !ok { |
| 143 | return ®Error{ |
| 144 | Status: http.StatusNotFound, |
| 145 | Code: "MANIFEST_UNKNOWN", |
| 146 | Message: "Unknown manifest", |
| 147 | } |
| 148 | } |
| 149 | |
| 150 | h, _, _ := v1.SHA256(bytes.NewReader(m.blob)) |
| 151 | resp.Header().Set("Docker-Content-Digest", h.String()) |
nothing calls this directly
no test coverage detected