UpdateNotes handles PATCH /hosts/:hostId/notes.
(w http.ResponseWriter, r *http.Request)
| 300 | |
| 301 | // UpdateNotes handles PATCH /hosts/:hostId/notes. |
| 302 | func (h *HostsHandler) UpdateNotes(w http.ResponseWriter, r *http.Request) { |
| 303 | hostID := chi.URLParam(r, "hostId") |
| 304 | var req struct { |
| 305 | Notes *string `json:"notes"` |
| 306 | } |
| 307 | if err := decodeJSON(r, &req); err != nil { |
| 308 | Error(w, http.StatusBadRequest, "Invalid request body") |
| 309 | return |
| 310 | } |
| 311 | |
| 312 | if err := h.hosts.UpdateNotes(r.Context(), hostID, req.Notes); err != nil { |
| 313 | Error(w, http.StatusInternalServerError, "Failed to update notes") |
| 314 | return |
| 315 | } |
| 316 | host, _ := h.hosts.GetByID(r.Context(), hostID) |
| 317 | groups, _ := h.hosts.GetHostGroups(r.Context(), hostID) |
| 318 | JSON(w, http.StatusOK, map[string]interface{}{ |
| 319 | "message": "Notes updated successfully", |
| 320 | "host": hostToResponse(host, groups), |
| 321 | }) |
| 322 | } |
| 323 | |
| 324 | // UpdateConnection handles PATCH /hosts/:hostId/connection. |
| 325 | func (h *HostsHandler) UpdateConnection(w http.ResponseWriter, r *http.Request) { |
nothing calls this directly
no test coverage detected