MCPcopy Index your code
hub / github.com/netdata/netdata / SendJSONWithCode

Method SendJSONWithCode

src/go/plugin/framework/dyncfg/responder.go:88–103  ·  view source on GitHub ↗

SendJSONWithCode sends a JSON payload response with a specific HTTP status code

(fn Function, payload string, code int)

Source from the content-addressed store, hash-verified

86
87// SendJSONWithCode sends a JSON payload response with a specific HTTP status code
88func (r *Responder) SendJSONWithCode(fn Function, payload string, code int) {
89 if fn.UID() == "" {
90 return
91 }
92
93 res := netdataapi.FunctionResult{
94 UID: fn.UID(),
95 ContentType: "application/json",
96 Payload: payload,
97 Code: strconv.Itoa(code),
98 ExpireTimestamp: strconv.FormatInt(time.Now().Unix(), 10),
99 }
100 r.finalizeTerminal(fn.UID(), "dyncfg.responder.sendjsonwithcode", func() {
101 r.api.FUNCRESULT(res)
102 })
103}
104
105// SendYAML sends a YAML payload response
106func (r *Responder) SendYAML(fn Function, payload string) {

Callers 1

sendJSONMethod · 0.80

Calls 3

finalizeTerminalMethod · 0.95
FUNCRESULTMethod · 0.80
UIDMethod · 0.65

Tested by

no test coverage detected