Class: Zitadel::Client::TransportOptions
- Inherits:
-
Object
- Object
- Zitadel::Client::TransportOptions
- Defined in:
- lib/zitadel/client/transport_options.rb
Overview
Immutable transport options for configuring HTTP connections.
Instance Attribute Summary collapse
-
#ca_cert_path ⇒ String?
readonly
Path to a custom CA certificate file for TLS verification.
-
#default_headers ⇒ Hash{String => String}
readonly
Default HTTP headers sent to the origin server with every request.
-
#insecure ⇒ Boolean
readonly
Whether to disable TLS certificate verification.
-
#proxy_url ⇒ String?
readonly
Proxy URL for HTTP connections.
Class Method Summary collapse
-
.defaults ⇒ TransportOptions
Returns a TransportOptions instance with all default values.
Instance Method Summary collapse
-
#initialize(default_headers: {}, ca_cert_path: nil, insecure: false, proxy_url: nil) ⇒ TransportOptions
constructor
Creates a new TransportOptions instance.
-
#to_connection_opts ⇒ Hash
Builds Faraday connection options from these transport options.
Constructor Details
#initialize(default_headers: {}, ca_cert_path: nil, insecure: false, proxy_url: nil) ⇒ TransportOptions
Creates a new TransportOptions instance.
28 29 30 31 32 33 34 |
# File 'lib/zitadel/client/transport_options.rb', line 28 def initialize(default_headers: {}, ca_cert_path: nil, insecure: false, proxy_url: nil) @default_headers = default_headers.dup.freeze @ca_cert_path = ca_cert_path&.dup&.freeze @insecure = insecure @proxy_url = proxy_url&.dup&.freeze freeze end |
Instance Attribute Details
#ca_cert_path ⇒ String? (readonly)
Returns Path to a custom CA certificate file for TLS verification.
13 14 15 |
# File 'lib/zitadel/client/transport_options.rb', line 13 def ca_cert_path @ca_cert_path end |
#default_headers ⇒ Hash{String => String} (readonly)
Returns Default HTTP headers sent to the origin server with every request.
10 11 12 |
# File 'lib/zitadel/client/transport_options.rb', line 10 def default_headers @default_headers end |
#insecure ⇒ Boolean (readonly)
Returns Whether to disable TLS certificate verification.
16 17 18 |
# File 'lib/zitadel/client/transport_options.rb', line 16 def insecure @insecure end |
#proxy_url ⇒ String? (readonly)
Returns Proxy URL for HTTP connections.
19 20 21 |
# File 'lib/zitadel/client/transport_options.rb', line 19 def proxy_url @proxy_url end |
Class Method Details
.defaults ⇒ TransportOptions
Returns a TransportOptions instance with all default values.
39 40 41 |
# File 'lib/zitadel/client/transport_options.rb', line 39 def self.defaults new end |
Instance Method Details
#to_connection_opts ⇒ Hash
Builds Faraday connection options from these transport options.
rubocop:disable Metrics/AbcSize, Metrics/MethodLength
47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/zitadel/client/transport_options.rb', line 47 def to_connection_opts opts = {} if insecure opts[:ssl] = { verify: false } elsif ca_cert_path store = OpenSSL::X509::Store.new store.set_default_paths store.add_file(ca_cert_path) opts[:ssl] = { cert_store: store, verify: true } end opts[:proxy] = proxy_url if proxy_url opts[:headers] = default_headers.dup if default_headers.any? opts end |