MCPcopy Create free account
hub / github.com/cloudwan/gohan / handleResponse

Method handleResponse

cli/client/commands.go:342–360  ·  view source on GitHub ↗
(response *http.Response, err error)

Source from the content-addressed store, hash-verified

340}
341
342func (gohanClientCLI *GohanClientCLI) handleResponse(response *http.Response, err error) (interface{}, error) {
343 if response == nil {
344 return nil, fmt.Errorf(noResponseError)
345 }
346 defer response.Body.Close()
347 var result interface{}
348 json.NewDecoder(response.Body).Decode(&result)
349
350 gohanClientCLI.logResponse(response.Status, result)
351
352 if response.StatusCode == http.StatusNotFound {
353 return nil, fmt.Errorf(resourceNotFoundError)
354 }
355 if err != nil {
356 return nil, fmt.Errorf(unexpectedResponse, response.Status)
357 }
358
359 return result, err
360}
361
362func (gohanClientCLI *GohanClientCLI) getFieldsParam(prependQuestionMark bool) string {
363 if len(gohanClientCLI.opts.fields) == 0 {

Callers 2

requestMethod · 0.95
getResourceIDMethod · 0.95

Calls 3

logResponseMethod · 0.95
ErrorfMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected