Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make response body accessible on ClientResp #82

Merged
merged 2 commits into from
Jun 6, 2022

Conversation

mikekavouras
Copy link
Contributor

@mikekavouras mikekavouras commented May 3, 2022

👋 This change exposes the Twirp response body via a new body attribute on ClientResp. The reason for this change is to make it easier for consumers to cache the raw response. The currently exposed data attribute is decoded and not cachable.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

cached_body = Rails.cache.fetch(cache_key) do 
  resp = Twirp::Client.new(faraday_client).get_resource
  resp.body
end

# later...

MsgClass.decode(cached_body)

cc @zrdaley for help putting this together

@wmatveyenko
Copy link
Collaborator

Hi @mikekavouras, can you add "By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license." to your PR?
Thanks!

@mikekavouras
Copy link
Contributor Author

@wmatveyenko done!

@wmatveyenko wmatveyenko merged commit 4614a5f into arthurnn:main Jun 6, 2022
@wmatveyenko
Copy link
Collaborator

Thanks for the contribution

@mikekavouras mikekavouras deleted the client-resp-body branch July 14, 2022 01:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants