Skip to content

Make response body accessible on ClientResp#82

Merged
wmatveyenko merged 2 commits intoarthurnn:mainfrom
mikekavouras:client-resp-body
Jun 6, 2022
Merged

Make response body accessible on ClientResp#82
wmatveyenko merged 2 commits intoarthurnn:mainfrom
mikekavouras:client-resp-body

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

mikekavouras and others added 2 commits May 2, 2022 18:02
Co-Authored-By: Zenara Daley <17059671+zrdaley@users.noreply.github.com>
Co-Authored-By: Zenara Daley <17059671+zrdaley@users.noreply.github.com>
@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