MCPcopy
hub / github.com/PatchMon/PatchMon / JSON

Function JSON

server-source-code/internal/handler/response.go:9–15  ·  view source on GitHub ↗

JSON writes a JSON response.

(w http.ResponseWriter, status int, v interface{})

Source from the content-addressed store, hash-verified

7
8// JSON writes a JSON response.
9func JSON(w http.ResponseWriter, status int, v interface{}) {
10 w.Header().Set("Content-Type", "application/json")
11 w.WriteHeader(status)
12 if v != nil {
13 _ = json.NewEncoder(w).Encode(v)
14 }
15}
16
17// Error writes a JSON error response.
18func Error(w http.ResponseWriter, status int, message string) {

Callers 15

ListMethod · 0.70
GetByHostMethod · 0.70
GetByIDMethod · 0.70
UpdateMethod · 0.70
ToggleHostRepositoryMethod · 0.70
GetStatsMethod · 0.70
DeleteMethod · 0.70
CleanupOrphanedMethod · 0.70
alertConfigSuccessDataFunction · 0.70
BulkUpdateMethod · 0.70
StatsMethod · 0.70
HostsMethod · 0.70

Calls 1

SetMethod · 0.45

Tested by

no test coverage detected