(respBody io.ReadCloser, statusCode int, respStruct interface{})
| 111 | } |
| 112 | |
| 113 | func 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 | |
| 127 | func BindAndValidate(logger g.LoggerType, c echo.Context, reqParam interface{}) error { |
| 128 | logger.Info("validate params") |
no test coverage detected