MCPcopy
hub / github.com/cortexlabs/cortex / respondJSON

Function respondJSON

pkg/operator/endpoints/respond.go:32–42  ·  view source on GitHub ↗
(w http.ResponseWriter, r *http.Request, response interface{})

Source from the content-addressed store, hash-verified

30var operatorLogger = logging.GetLogger()
31
32func respondJSON(w http.ResponseWriter, r *http.Request, response interface{}) {
33 jsonBytes, err := libjson.Marshal(response)
34 if err != nil {
35 respondError(w, r, errors.Wrap(err, "failed to encode response"))
36 return
37 }
38
39 w.Header().Set("Content-Type", "application/json")
40 w.WriteHeader(http.StatusOK)
41 w.Write(jsonBytes)
42}
43
44func respondError(w http.ResponseWriter, r *http.Request, err error, strs ...string) {
45 respondErrorCode(w, r, http.StatusBadRequest, err, strs...)

Callers 15

GetLogURLFunction · 0.70
StopTaskJobFunction · 0.70
GetTaskJobFunction · 0.70
StopBatchJobFunction · 0.70
GetJobLogURLFunction · 0.70
RefreshFunction · 0.70
SubmitTaskJobFunction · 0.70
DeleteFunction · 0.70
VerifyCortexFunction · 0.70
InfoFunction · 0.70
DescribeAPIFunction · 0.70
SubmitBatchJobFunction · 0.70

Calls 4

WrapFunction · 0.92
respondErrorFunction · 0.85
SetMethod · 0.80
WriteMethod · 0.80

Tested by

no test coverage detected