MCPcopy Create free account
hub / github.com/actiontech/dtle / handleNomadResponse

Function handleNomadResponse

api/handler/common.go:113–125  ·  view source on GitHub ↗
(respBody io.ReadCloser, statusCode int, respStruct interface{})

Source from the content-addressed store, hash-verified

111}
112
113func handleNomadResponse(respBody io.ReadCloser, statusCode int, respStruct interface{}) error {
114 body, err := ioutil.ReadAll(respBody)
115 if err != nil {
116 return fmt.Errorf("read response body failed, error: %v", err)
117 }
118 if statusCode/100 != 2 {
119 return fmt.Errorf("got error response, statusCode=%v, got response: %v", statusCode, string(body))
120 }
121 if err := json.Unmarshal(body, &respStruct); nil != err {
122 return fmt.Errorf("parse response failed. got response: %v", string(body))
123 }
124 return nil
125}
126
127func BindAndValidate(logger g.LoggerType, c echo.Context, reqParam interface{}) error {
128 logger.Info("validate params")

Callers 3

InvokeApiWithKvDataFunction · 0.85
InvokePostApiWithJsonFunction · 0.85
InvokeHttpUrlWithBodyFunction · 0.85

Calls 1

UnmarshalMethod · 0.65

Tested by

no test coverage detected