MCPcopy Index your code
hub / github.com/go-dev-frame/sponge / Do

Method Do

pkg/httpcli/httpcli.go:171–197  ·  view source on GitHub ↗

Do a request

(method string, data interface{})

Source from the content-addressed store, hash-verified

169
170// Do a request
171func (req *Request) Do(method string, data interface{}) (*Response, error) {
172 req.method = method
173
174 switch method {
175 case http.MethodGet, http.MethodDelete:
176 if data != nil {
177 if params, ok := data.(map[string]interface{}); ok { //nolint
178 req.SetParams(params)
179 } else {
180 req.err = errors.New("params is not a map[string]interface{}")
181 return nil, req.err
182 }
183 }
184
185 return req.pull()
186
187 case http.MethodPost, http.MethodPut, http.MethodPatch:
188 if data != nil {
189 req.SetBody(data)
190 }
191
192 return req.push()
193 }
194
195 req.err = errors.New("unknow method " + method)
196 return nil, req.err
197}
198
199func (req *Request) pull() (*Response, error) {
200 val := ""

Callers 15

TestRequest_DoFunction · 0.95
GetGlobalMemoryCliFunction · 0.45
getUserFunction · 0.45
getUserFunction · 0.45
lazyInitMethod · 0.45
doFunction · 0.45
SetLoggerFunction · 0.45
StopHealthCheckMethod · 0.45
srvRegisterMetricsFunction · 0.45
cliRegisterMetricsFunction · 0.45

Calls 4

SetParamsMethod · 0.95
pullMethod · 0.95
SetBodyMethod · 0.95
pushMethod · 0.95

Tested by 6

TestRequest_DoFunction · 0.76
getUserFunction · 0.36
getUserFunction · 0.36
doFunction · 0.36