refactor(contrib/registry/eureka): weird http code 200 judgment

pull/2765/head
demoManito 2 years ago
parent f03f5f8988
commit 763d44c72e
  1. 13
      contrib/registry/eureka/client.go

@ -324,7 +324,11 @@ func (e *Client) request(ctx context.Context, method string, params []string, in
_ = resp.Body.Close()
}()
if output != nil && resp.StatusCode/100 == 2 {
if resp.StatusCode == http.StatusOK || resp.StatusCode == http.StatusNoContent {
if output == nil {
return false, nil
}
data, err := io.ReadAll(resp.Body)
if err != nil {
return false, err
@ -334,12 +338,7 @@ func (e *Client) request(ctx context.Context, method string, params []string, in
return false, err
}
}
if resp.StatusCode >= http.StatusBadRequest {
return false, fmt.Errorf("response Error %d", resp.StatusCode)
}
return false, nil
return false, fmt.Errorf("response error %d", resp.StatusCode)
}
func (e *Client) do(ctx context.Context, method string, params []string, input io.Reader, output interface{}) error {

Loading…
Cancel
Save