feat(rest): add faraday_config option to client configuration#1284
Open
aandreassa wants to merge 1 commit intomainfrom
Open
feat(rest): add faraday_config option to client configuration#1284aandreassa wants to merge 1 commit intomainfrom
aandreassa wants to merge 1 commit intomainfrom
Conversation
Exposes the internal Faraday::Connection customization hook to the public client layer. This enables advanced HTTP setup, such as mTLS client certificate configuration.
Instead of forwarding blocks through the client constructors (which collides with the existing configuration blocks), we introduced a config.faraday_config attribute.
This approach isolates transport specific details, allows clean automated propagation to internal subclients (LROs and mixins), and uses a standard respond_to? check to preserve perfect backward compatibility with legacy external gems.
Example Usage
```ruby
client = Google::Cloud::Language::V1::LanguageService::Rest::Client.new do |config|
config.faraday_config = ->(conn) do
conn.ssl.client_cert = OpenSSL::X509::Certificate.new cert_pem
conn.ssl.client_key = OpenSSL::PKey::RSA.new key_pem
end
end
```
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Addresses issue googleapis/ruby-core-libraries#57.
While
gapic-commonalready supports yielding theFaraday::ConnectioninsideClientStub, this hook was unreachable from auto-generated client libraries. This PR exposes that capability to the public client layer, enabling advanced HTTP customization like mTLS client certificate configuration.Design
Instead of forwarding blocks through the client constructors (which collides with the existing configuration blocks), we introduce a
config.faraday_configattribute.This approach isolates transport specific details, allows clean automated propagation to internal subclients (LROs and mixins), and has a
respond_to?check to preserve perfect backward compatibility with legacy gems versions.Example Usage