SendJSONWithCode sends a JSON payload response with a specific HTTP status code
(fn Function, payload string, code int)
| 86 | |
| 87 | // SendJSONWithCode sends a JSON payload response with a specific HTTP status code |
| 88 | func (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 |
| 106 | func (r *Responder) SendYAML(fn Function, payload string) { |
no test coverage detected