Skip to content

Commit

Permalink
fix fatal if type returned by API is different
Browse files Browse the repository at this point in the history
  • Loading branch information
andreas-goebel committed Feb 7, 2024
1 parent bf3293b commit aef0516
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,10 @@ func ReadWithStatusCode[T any](request *http.Request, timeout time.Duration, che
return value, statusCode, nil
} else if _, ok := interface{}(value).(string); ok {
return any(string(payload)).(T), statusCode, nil
} else if _, ok := interface{}(value).([]byte); ok {
return any(string(payload)).(T), statusCode, nil
} else {
return any(payload).(T), statusCode, nil
return value, statusCode, fmt.Errorf("can't use payload as type %T", value)
}
}

Expand Down

0 comments on commit aef0516

Please sign in to comment.