Repository navigation
Replies: 1 comment
|
Adding docs link reference: https://resty.dev/docs/unlimited-response-body-reads/ |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
I'm adding this for anyone who find this. I had originally searched the documentation about caveats related to middleware that reads the response content, and found nothing specific. I eventually read the code for the existing middleware. I originally had something like this:
In English, I want to be able to have middleware that can read the JSON body of the response for all actions on a client. I then use this data in an aggregator, which doesn't really matter here.
My issue was that if I read the response body I will end up with an error
unmarshal json: unexpected end of JSON inputlater. The code that reads later is of the form:I found that my code above does not work. The solution is much simpler, and more elegant.
Bytes()helper.Example:
Hopefully this saves someone the couple hours it cost me. Or an AI or something. Who knows anymore...
All reactions