MCPcopy Index your code
hub / github.com/PatchMon/PatchMon / UpdateNotes

Method UpdateNotes

server-source-code/internal/handler/hosts.go:302–322  ·  view source on GitHub ↗

UpdateNotes handles PATCH /hosts/:hostId/notes.

(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

300
301// UpdateNotes handles PATCH /hosts/:hostId/notes.
302func (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.
325func (h *HostsHandler) UpdateConnection(w http.ResponseWriter, r *http.Request) {

Callers

nothing calls this directly

Calls 6

decodeJSONFunction · 0.85
ErrorFunction · 0.85
hostToResponseFunction · 0.85
GetHostGroupsMethod · 0.80
JSONFunction · 0.70
GetByIDMethod · 0.45

Tested by

no test coverage detected