Closed T-J-L closed 3 years ago
In response to "I actually have no idea of how to switch encoders in Twirp. Maybe it's not even possible.", this can't be done out of the box with the code generation, but can be achieved (server-side) with a simple find and replace.
The changes are below:
proto.Marshal(respContent) >> respContent.MarshalVT() proto.Unmarshal(buf, reqContent) >> reqContent.UnmarshalVT(buf)
I'm using make to control all code gen, so I added the below as a final step:
for twirp in $${dir}/*.twirp.go; \ do \ echo 'Updating' $${twirp}; \ sed -i '' -e 's/respBytes, err := proto.Marshal(respContent)/respBytes, err := respContent.MarshalVT()/g' $${twirp}; \ sed -i '' -e 's/if err = proto.Unmarshal(buf, reqContent); err != nil {/if err = reqContent.UnmarshalVT(buf); err != nil {/g' $${twirp}; \ done; \
See https://github.com/twitchtv/twirp/issues/327 for further discussion.
Thank you! I've updated the README with your example!
In response to "I actually have no idea of how to switch encoders in Twirp. Maybe it's not even possible.", this can't be done out of the box with the code generation, but can be achieved (server-side) with a simple find and replace.
The changes are below:
I'm using make to control all code gen, so I added the below as a final step: