MCPcopy
hub / github.com/cli/cli / StatusJSONResponse

Function StatusJSONResponse

pkg/httpmock/stub.go:175–183  ·  view source on GitHub ↗

StatusJSONResponse turns the given argument into a JSON response. The argument is not meant to be a JSON string, unless it's intentional.

(status int, body interface{})

Source from the content-addressed store, hash-verified

173//
174// The argument is not meant to be a JSON string, unless it's intentional.
175func StatusJSONResponse(status int, body interface{}) Responder {
176 return func(req *http.Request) (*http.Response, error) {
177 b, _ := json.Marshal(body)
178 header := http.Header{
179 "Content-Type": []string{"application/json"},
180 }
181 return httpResponseWithHeader(status, req, bytes.NewBuffer(b), header), nil
182 }
183}
184
185// JSONErrorResponse is a type-safe helper to avoid confusion around the
186// provided argument.

Callers 12

TestAutolinkLister_ListFunction · 0.92
Test_SyncRunFunction · 0.92
TestNewVerifyCmdFunction · 0.92
TestSearchRunFunction · 0.92
TestFindWorkflowFunction · 0.92
TestGetWorkflowsFunction · 0.92
TestRunFunction · 0.92
JSONErrorResponseFunction · 0.85

Calls 1

httpResponseWithHeaderFunction · 0.85

Tested by 11

TestAutolinkLister_ListFunction · 0.74
Test_SyncRunFunction · 0.74
TestNewVerifyCmdFunction · 0.74
TestSearchRunFunction · 0.74
TestFindWorkflowFunction · 0.74
TestGetWorkflowsFunction · 0.74
TestRunFunction · 0.74