Closed BrunoKrugel closed 11 months ago
I also found these two related issues:
.String()
instead of .Body()
RawResponse
and the body
.@BrunoKrugel Thanks for reaching out. I will add Response.SetBody(b []byte)
method.
@BrunoKrugel Currently, it's available in v2.10.0-rc.2
. Can you please try it out?
In our tests, we use mockery, so we can mock the return value of our methods.
If I isolate my HTTP request in a method and return the
resty.Response
struct, I cannot mock thebody
value.In the following example, my
GetData()
method will call theSendPostRequest()
method that is mocked, with mockery I will set the value return from theSendPostRequest()
, that will be used afterwards inGetData()
.If I try to access the
Body
value from theresponse.Body()
it will return nill, bacause the method returns the value from theResponse
struct, which is private.All the other methods/values available in the Response struct, return the value from the
RawResponse
(for example theStatusCode
orStatus
), only the value ofbody
comes from a different source.Why the Body method check for
RawResponse
value if it will return the value ofbody
instead ofResponse.Body
?How can I set a custom
body
value directly in the Response structure instead of theRawResponse
? So I can get the value withBody()
.