MCPcopy
hub / github.com/netdata/netdata / BuildJSONPayload

Function BuildJSONPayload

src/go/plugin/framework/functions/response_payload.go:8–28  ·  view source on GitHub ↗

BuildJSONPayload builds the standard JSON payload used by function terminal responses.

(code int, message string)

Source from the content-addressed store, hash-verified

6
7// BuildJSONPayload builds the standard JSON payload used by function terminal responses.
8func BuildJSONPayload(code int, message string) []byte {
9 if code >= 400 && code < 600 {
10 bs, _ := json.Marshal(struct {
11 Status int `json:"status"`
12 ErrorMessage string `json:"errorMessage"`
13 }{
14 Status: code,
15 ErrorMessage: message,
16 })
17 return bs
18 }
19
20 bs, _ := json.Marshal(struct {
21 Status int `json:"status"`
22 Message string `json:"message"`
23 }{
24 Status: code,
25 Message: message,
26 })
27 return bs
28}

Callers 2

respfMethod · 0.85
TestBuildJSONPayloadFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestBuildJSONPayloadFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…