MCPcopy Index your code
hub / github.com/apache/answer / requestAPI

Function requestAPI

internal/install/install_from_env.go:137–150  ·  view source on GitHub ↗
(req any, method, url string, handlerFunc gin.HandlerFunc)

Source from the content-addressed store, hash-verified

135}
136
137func requestAPI(req any, method, url string, handlerFunc gin.HandlerFunc) error {
138 w := httptest.NewRecorder()
139 c, _ := gin.CreateTestContext(w)
140 body, _ := json.Marshal(req)
141 c.Request, _ = http.NewRequest(method, url, bytes.NewBuffer(body))
142 if method == "POST" {
143 c.Request.Header.Set("Content-Type", "application/json")
144 }
145 handlerFunc(c)
146 if w.Code != http.StatusOK {
147 return errors.New(gjson.Get(w.Body.String(), "msg").String())
148 }
149 return nil
150}

Callers 3

dbCheckFunction · 0.85
initConfigAndDbFunction · 0.85
initBaseInfoFunction · 0.85

Calls 2

SetMethod · 0.80
GetMethod · 0.45

Tested by

no test coverage detected