MCPcopy
hub / github.com/harness/harness / AddPackageTag

Method AddPackageTag

registry/app/api/handler/npm/add_tag.go:27–50  ·  view source on GitHub ↗
(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

25)
26
27func (h *handler) AddPackageTag(w http.ResponseWriter, r *http.Request) {
28 contextInfo := request.ArtifactInfoFrom(r.Context())
29 info, ok := contextInfo.(npm2.ArtifactInfo)
30 if !ok {
31 h.HandleErrors2(r.Context(), errcode.ErrCodeInvalidRequest.WithMessage("failed to fetch info from context"), w)
32 return
33 }
34 response := h.controller.AddTag(r.Context(), info)
35 if commons.IsEmpty(response.GetError()) {
36 jsonResponse, err := json.Marshal(response.Tags)
37 if err != nil {
38 http.Error(w, "Error encoding response", http.StatusInternalServerError)
39 return
40 }
41
42 w.Header().Set("Content-Type", "application/json")
43 w.WriteHeader(http.StatusOK)
44 _, err = w.Write(jsonResponse)
45 if err != nil {
46 http.Error(w, "Failed to write response", http.StatusInternalServerError)
47 }
48 }
49 h.HandleError(r.Context(), w, response.GetError())
50}

Callers

nothing calls this directly

Calls 12

HandleErrors2Method · 0.95
HandleErrorMethod · 0.95
ArtifactInfoFromFunction · 0.92
IsEmptyFunction · 0.92
AddTagMethod · 0.65
GetErrorMethod · 0.65
ErrorMethod · 0.65
SetMethod · 0.65
WriteMethod · 0.65
WithMessageMethod · 0.45
HeaderMethod · 0.45
WriteHeaderMethod · 0.45

Tested by

no test coverage detected