(w http.ResponseWriter, r *http.Request)
| 68 | } |
| 69 | |
| 70 | func (h *Handler) handleGetItem(w http.ResponseWriter, r *http.Request) { |
| 71 | id := strings.TrimPrefix(r.URL.Path, "/api/items/") |
| 72 | if id == "" { |
| 73 | http.NotFound(w, r) |
| 74 | return |
| 75 | } |
| 76 | |
| 77 | writeJSON(w, http.StatusOK, model.ItemResponse{ |
| 78 | Item: model.DataItem{ |
| 79 | ID: 1, |
| 80 | Name: "Sample Item " + id, |
| 81 | Value: 100, |
| 82 | }, |
| 83 | Timestamp: time.Now().UTC().Format(time.RFC3339), |
| 84 | }) |
| 85 | } |
| 86 | |
| 87 | func writeJSON(w http.ResponseWriter, status int, v any) { |
| 88 | w.Header().Set("Content-Type", "application/json") |
nothing calls this directly
no test coverage detected