(w http.ResponseWriter, r *http.Request)
| 25 | ) |
| 26 | |
| 27 | func (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 | } |
nothing calls this directly
no test coverage detected