MCPcopy Create free account
hub / github.com/Mnexa-AI/e2a / postJSON

Function postJSON

internal/httpapi/agents_write_test.go:78–94  ·  view source on GitHub ↗
(t *testing.T, url, bearer string, body any)

Source from the content-addressed store, hash-verified

76}
77
78func postJSON(t *testing.T, url, bearer string, body any) (int, map[string]any) {
79 t.Helper()
80 b, _ := json.Marshal(body)
81 req, _ := http.NewRequest("POST", url, bytes.NewReader(b))
82 req.Header.Set("Content-Type", "application/json")
83 if bearer != "" {
84 req.Header.Set("Authorization", "Bearer "+bearer)
85 }
86 resp, err := http.DefaultClient.Do(req)
87 if err != nil {
88 t.Fatal(err)
89 }
90 defer resp.Body.Close()
91 var out map[string]any
92 _ = json.NewDecoder(resp.Body).Decode(&out)
93 return resp.StatusCode, out
94}
95
96func errCode(body map[string]any) string {
97 if e, ok := body["error"].(map[string]any); ok {

Callers 15

TestRegisterDomainFunction · 0.85
TestVerifyDomainSuccessFunction · 0.85
TestVerifyDomainNotFoundFunction · 0.85
TestRegRateLimitedFunction · 0.85
TestSendRateLimitedFunction · 0.85

Calls 1

CloseMethod · 0.45

Tested by

no test coverage detected